#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, unsigned int);
int main(int argc, char **argv) {
  int i = 0;
  unsigned int j = 0;
  FILE *infile;
  infile = fopen(argv[1], "r");
  fread(&i, 4, 1, infile);
  if (i < 0x20746e6A) {
    j = i;
    if (j > 0x80000000) {
      printf("Surprise! Bad inputs : %x %x \n", i, j);
      return 1;
    } else {
      printf("Good i < 0x20746e69 j < 0x80000000 input : %x %x \n", i, j);
    }
  } else {
    j = i;
    printf("Good inputs : %x %x \n", i, j);
  }
  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   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmpl   $0x20746e6a,-0x14(%rbp)
jge    11d8 <main+0xa8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x80000000,-0x18(%rbp)
jbe    11c1 <main+0x91>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f7 <main+0xc7>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
jmp    11f0 <main+0xc0>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
mov    0x8(%rsi),%rdi
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    0xc(%rsp),%edx
xor    %ebx,%ebx
cmp    $0x80000001,%edx
setae  %bl
lea    0xe88(%rip),%rax
lea    0xea0(%rip),%rcx
cmovae %rax,%rcx
cmp    $0x20746e6a,%edx
lea    0xec2(%rip),%rdi
cmovl  %rcx,%rdi
mov    %edx,%esi
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [31 x i8] c"Surprise! Bad inputs : %x %x \0A\00"
@.str.2 = [51 x i8] c"Good i < 0x20746e69 j < 0x80000000 input : %x %x \0A\00"
@.str.3 = [22 x i8] c"Good inputs : %x %x \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %8
%13 = load i32*, i32** %8
%14 = call i32 @fread(i32* %6, i32 4, i32 1, i32* %13)
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 544501354
br i1 %16, label %17, label %30
17: ; preds = %2
%18 = load i32, i32* %6
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp ugt i32 %19, -2147483648
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23)
store i32 1, i32* %3
br label %36
25: ; preds = %17
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %26, i32 %27)
br label %29
29: ; preds = %25
br label %35
30: ; preds = %2
%31 = load i32, i32* %6
store i32 %31, i32* %7
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %32, i32 %33)
br label %35
35: ; preds = %30, %29
store i32 0, i32* %3
br label %36
36: ; preds = %35, %21
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [31 x i8] c"Surprise! Bad inputs : %x %x \0A\00"
@.str.2 = [51 x i8] c"Good i < 0x20746e69 j < 0x80000000 input : %x %x \0A\00"
@.str.3 = [22 x i8] c"Good inputs : %x %x \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %7)
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 544501354
%11 = icmp ugt i32 %9, -2147483648
%12 = select i1 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0)
%13 = select i1 %10, i8* %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0)
%14 = zext i1 %11 to i32
%15 = tail call i32 @printf(i8* %13, i32 %9, i32 %9)
ret i32 %14
}