#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 atoi(char *);
int get_min(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ test();
int validate(int, int);
int main(int argc, char **argv) {
  int x = 3;
  if (argc > 1) {
    x = atoi(argv[1]);
  } else {
    test();
  }
  printf("x: %d\n", x);
  printf("y: %d\n", get_min(x));
  printf("validate 321: %d\n", validate(321, get_min(321)));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    118c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    1193 <main+0x43>
mov    $0x0,%al
call   1070 <test@plt>
mov    -0x14(%rbp),%esi
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <get_min@plt>
mov    %eax,%esi
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
mov    $0x141,%edi
call   1030 <get_min@plt>
mov    %eax,%esi
mov    $0x141,%edi
call   1050 <validate@plt>
mov    %eax,%esi
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jl     1163 <main+0x13>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
jmp    116f <main+0x1f>
xor    %eax,%eax
call   1070 <test@plt>
mov    $0x3,%ebx
lea    0xe8a(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1030 <get_min@plt>
lea    0xe7c(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x141,%edi
call   1030 <get_min@plt>
mov    $0x141,%edi
mov    %eax,%esi
call   1050 <validate@plt>
lea    0xe5f(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"x: %d\0A\00"
@.str.1 = [7 x i8] c"y: %d\0A\00"
@.str.2 = [18 x i8] c"validate 321: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %6
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %6
br label %16
14: ; preds = %2
%15 = call i32 (...) @test()
br label %16
16: ; preds = %14, %9
%17 = load i32, i32* %6
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %6
%20 = call i32 @get_min(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = call i32 @get_min(i32 321)
%23 = call i32 @validate(i32 321, i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"x: %d\0A\00"
@.str.1 = [7 x i8] c"y: %d\0A\00"
@.str.2 = [18 x i8] c"validate 321: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %10
8: ; preds = %2
%9 = tail call i32 (...) @test()
br label %10
10: ; preds = %8, %4
%11 = phi i32 [ %7, %4 ], [ 3, %8 ]
%12 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = tail call i32 @get_min(i32 %11)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = tail call i32 @get_min(i32 321)
%16 = tail call i32 @validate(i32 321, i32 %15)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %16)
ret i32 0
}