#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 /*<<< orphan*/ small(int);
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  char string[] = "a very long string variable saved in the stack memory";
  int n = 123456;
  int i;
  if (argc > 1)
    n = atoi(argv[1]);
  else if (argc > 2)
    n = strtol(argv[1], NULL, atoi(argv[2]));
  small(n ? n : 123456);
  for (i = 0; i < 4; i++) {
    static volatile unsigned x = 42;
    x *= 1 << i;
    x ^= 0xdeadbeef;
    x >>= i;
    if (x == 0)
      x = (unsigned)string[i] << i;
  }
  return n ? (n ^ n) : 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x36,%edx
call   1040 <memcpy@plt>
movl   $0x1e240,-0x54(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1191 <main+0x51>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x54(%rbp)
jmp    11cb <main+0x8b>
cmpl   $0x2,-0x8(%rbp)
jle    11c6 <main+0x86>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%edx
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtol@plt>
mov    %eax,-0x54(%rbp)
jmp    11cb <main+0x8b>
cmpl   $0x0,-0x54(%rbp)
je     11e0 <main+0xa0>
mov    -0x54(%rbp),%eax
mov    %eax,-0x64(%rbp)
jmp    11ed <main+0xad>
mov    $0x1e240,%eax
mov    %eax,-0x64(%rbp)
jmp    11ed <main+0xad>
mov    -0x64(%rbp),%edi
call   1050 <small@plt>
movl   $0x0,-0x58(%rbp)
cmpl   $0x4,-0x58(%rbp)
jge    1279 <main+0x139>
mov    -0x58(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
mov    0x2e28(%rip),%eax
imul   %ecx,%eax
mov    %eax,0x2e1f(%rip)
mov    0x2e19(%rip),%eax
xor    $0xdeadbeef,%eax
mov    %eax,0x2e0e(%rip)
mov    -0x58(%rbp),%ecx
mov    0x2e05(%rip),%eax
shr    %cl,%eax
mov    %eax,0x2dfd(%rip)
mov    0x2df7(%rip),%eax
cmp    $0x0,%eax
jne    1266 <main+0x126>
movslq -0x58(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
mov    -0x58(%rbp),%ecx
shl    %cl,%eax
mov    %eax,0x2dda(%rip)
jmp    126b <main+0x12b>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11fc <main+0xbc>
cmpl   $0x0,-0x54(%rbp)
je     1291 <main+0x151>
mov    -0x54(%rbp),%eax
xor    -0x54(%rbp),%eax
mov    %eax,-0x68(%rbp)
jmp    129b <main+0x15b>
xor    %eax,%eax
mov    %eax,-0x68(%rbp)
jmp    129b <main+0x15b>
mov    -0x68(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %edi,%eax
mov    $0x1e240,%edi
cmp    $0x2,%eax
jl     1140 <main+0x20>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
test   %eax,%eax
mov    $0x1e240,%edi
cmovne %eax,%edi
call   1030 <small@plt>
mov    0x2ee5(%rip),%eax
mov    %eax,0x2edf(%rip)
xorl   $0xdeadbeef,0x2ed5(%rip)
be ad de
mov    0x2ecf(%rip),%eax
mov    %eax,0x2ec9(%rip)
cmpl   $0x0,0x2ec2(%rip)
jne    117a <main+0x5a>
movl   $0x61,0x2eb6(%rip)
shll   0x2eb0(%rip)
xorl   $0xdeadbeef,0x2ea6(%rip)
be ad de
shrl   0x2ea0(%rip)
cmpl   $0x0,0x2e99(%rip)
jne    11a3 <main+0x83>
movl   $0x40,0x2e8d(%rip)
shll   $0x2,0x2e86(%rip)
xorl   $0xdeadbeef,0x2e7c(%rip)
be ad de
shrl   $0x2,0x2e75(%rip)
cmpl   $0x0,0x2e6e(%rip)
jne    11ce <main+0xae>
movl   $0x1d8,0x2e62(%rip)
shll   $0x3,0x2e5b(%rip)
xorl   $0xdeadbeef,0x2e51(%rip)
be ad de
shrl   $0x3,0x2e4a(%rip)
cmpl   $0x0,0x2e43(%rip)
jne    11f9 <main+0xd9>
movl   $0x328,0x2e37(%rip)
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.string = [54 x i8] c"a very long string variable saved in the stack memory\00"
@main.x = internal global i32 42
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [54 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [54 x i8]* %6 to i8*
store i32 123456, i32* %7
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %7
br label %30
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 2
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
%28 = call i32 @strtol(i8* %23, i32* null, i32 %27)
store i32 %28, i32* %7
br label %29
29: ; preds = %20, %17
br label %30
30: ; preds = %29, %12
%31 = load i32, i32* %7
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = load i32, i32* %7
br label %36
35: ; preds = %30
br label %36
36: ; preds = %35, %33
%37 = phi i32 [ %34, %33 ], [ 123456, %35 ]
%38 = call i32 @small(i32 %37)
store i32 0, i32* %8
br label %39
39: ; preds = %63, %36
%40 = load i32, i32* %8
%41 = icmp slt i32 %40, 4
br i1 %41, label %42, label %66
42: ; preds = %39
%43 = load i32, i32* %8
%44 = shl i32 1, %43
%45 = load volatile i32, i32* @main.x
%46 = mul i32 %45, %44
store volatile i32 %46, i32* @main.x
%47 = load volatile i32, i32* @main.x
%48 = xor i32 %47, -559038737
store volatile i32 %48, i32* @main.x
%49 = load i32, i32* %8
%50 = load volatile i32, i32* @main.x
%51 = lshr i32 %50, %49
store volatile i32 %51, i32* @main.x
%52 = load volatile i32, i32* @main.x
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %42
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [54 x i8], [54 x i8]* %6, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = load i32, i32* %8
%61 = shl i32 %59, %60
store volatile i32 %61, i32* @main.x
br label %62
62: ; preds = %54, %42
br label %63
63: ; preds = %62
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
br label %39
66: ; preds = %39
%67 = load i32, i32* %7
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %66
%70 = load i32, i32* %7
%71 = load i32, i32* %7
%72 = xor i32 %70, %71
br label %74
73: ; preds = %66
br label %74
74: ; preds = %73, %69
%75 = phi i32 [ %72, %69 ], [ 0, %73 ]
ret i32 %75
}

LLVM IR (-O2):
@main.x = internal global i32 42
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i32 123456, i32 %7
br label %10
10: ; preds = %4, %2
%11 = phi i32 [ 123456, %2 ], [ %9, %4 ]
%12 = tail call i32 @small(i32 %11)
%13 = load volatile i32, i32* @main.x
store volatile i32 %13, i32* @main.x
%14 = load volatile i32, i32* @main.x
%15 = xor i32 %14, -559038737
store volatile i32 %15, i32* @main.x
%16 = load volatile i32, i32* @main.x
store volatile i32 %16, i32* @main.x
%17 = load volatile i32, i32* @main.x
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %10
store volatile i32 97, i32* @main.x
br label %20
20: ; preds = %10, %19
%21 = load volatile i32, i32* @main.x
%22 = shl i32 %21, 1
store volatile i32 %22, i32* @main.x
%23 = load volatile i32, i32* @main.x
%24 = xor i32 %23, -559038737
store volatile i32 %24, i32* @main.x
%25 = load volatile i32, i32* @main.x
%26 = lshr i32 %25, 1
store volatile i32 %26, i32* @main.x
%27 = load volatile i32, i32* @main.x
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %20
store volatile i32 64, i32* @main.x
br label %30
30: ; preds = %29, %20
%31 = load volatile i32, i32* @main.x
%32 = shl i32 %31, 2
store volatile i32 %32, i32* @main.x
%33 = load volatile i32, i32* @main.x
%34 = xor i32 %33, -559038737
store volatile i32 %34, i32* @main.x
%35 = load volatile i32, i32* @main.x
%36 = lshr i32 %35, 2
store volatile i32 %36, i32* @main.x
%37 = load volatile i32, i32* @main.x
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %30
store volatile i32 472, i32* @main.x
br label %40
40: ; preds = %39, %30
%41 = load volatile i32, i32* @main.x
%42 = shl i32 %41, 3
store volatile i32 %42, i32* @main.x
%43 = load volatile i32, i32* @main.x
%44 = xor i32 %43, -559038737
store volatile i32 %44, i32* @main.x
%45 = load volatile i32, i32* @main.x
%46 = lshr i32 %45, 3
store volatile i32 %46, i32* @main.x
%47 = load volatile i32, i32* @main.x
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %40
store volatile i32 808, i32* @main.x
br label %50
50: ; preds = %49, %40
ret i32 0
}