#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int stub5(int, int);
int main() {
  int max(int, int);
  int min(int, int);
  int (*p)(int, int);
  int int_number_a, int_number_b, choice, c;
  printf("enter two numbers then find the max or min.\n");
  printf("please input a,b\n");
  scanf("%d,%d", &int_number_a, &int_number_b);
  printf("please choose 1(max)or 2(min):\n");
  scanf("%d", &choice);
  if (choice == 1)
    p = max;
  else if (choice == 2)
    p = min;
  c = (*p)(int_number_a, int_number_b);
  printf("a=%d,b=%d\n", int_number_a, int_number_b);
  if (choice == 1)
    printf("max=%d\n", c);
  else
    printf("min=%d\n", c);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    119b <main+0x7b>
mov    0x2e4e(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11b5 <main+0x95>
cmpl   $0x2,-0x1c(%rbp)
jne    11b0 <main+0x90>
mov    0x2e2c(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11b5 <main+0x95>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   *%rax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    11f8 <main+0xd8>
mov    -0x20(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1209 <main+0xe9>
mov    -0x20(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0xf05(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8b(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x2,0x4(%rsp)
jne    1194 <main+0x64>
mov    0x2e46(%rip),%rcx
jmp    119b <main+0x6b>
mov    0x2e45(%rip),%rcx
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   *%rcx
mov    %eax,%ebx
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x1,0x4(%rsp)
lea    0xe48(%rip),%rax
lea    0xe49(%rip),%rdi
cmove  %rax,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"enter two numbers then find the max or min.\0A\00"
@.str.1 = [18 x i8] c"please input a,b\0A\00"
@.str.2 = [6 x i8] c"%d,%d\00"
@.str.3 = [32 x i8] c"please choose 1(max)or 2(min):\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [11 x i8] c"a=%d,b=%d\0A\00"
@.str.6 = [8 x i8] c"max=%d\0A\00"
@.str.7 = [8 x i8] c"min=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32 (i32, i32)*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %0
store i32 (i32, i32)* @max, i32 (i32, i32)** %2
br label %20
15: ; preds = %0
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 (i32, i32)* @min, i32 (i32, i32)** %2
br label %19
19: ; preds = %18, %15
br label %20
20: ; preds = %19, %14
%21 = load i32 (i32, i32)*, i32 (i32, i32)** %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 %21(i32 %22, i32 %23)
store i32 %24, i32* %6
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %25, i32 %26)
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %33
30: ; preds = %20
%31 = load i32, i32* %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %31)
br label %36
33: ; preds = %20
%34 = load i32, i32* %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %30
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str.2 = [6 x i8] c"%d,%d\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [11 x i8] c"a=%d,b=%d\0A\00"
@.str.6 = [8 x i8] c"max=%d\0A\00"
@.str.7 = [8 x i8] c"min=%d\0A\00"
@str = [44 x i8] c"enter two numbers then find the max or min.\00"
@str.8 = [17 x i8] c"please input a,b\00"
@str.9 = [31 x i8] c"please choose 1(max)or 2(min):\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.9, i64 0, i64 0))
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 2
%14 = select i1 %13, i32 (i32, i32)* @min, i32 (i32, i32)* @max
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = call i32 %14(i32 %15, i32 %16)
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %18, i32 %19)
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 1
%23 = select i1 %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %23, i32 %17)
ret i32 0
}