#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*/ O_RDONLY;
int /*<<< orphan*/ check(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int main(int argc, char *argv[]) {
  char buffer[4];
  int i;
  volatile int j, k;
  int fd;
  if (argc != 2) {
    printf("Usage: %s <file>\n", argv[0]);
    exit(-1);
  }
  do {
    if (!((fd = open(argv[1], O_RDONLY)) != -1)) {
      perror("open");
      exit(-1);
    }
  } while (0);
  do {
    if (!(read(fd, buffer, 4) == 4)) {
      perror("read");
      exit(-1);
    }
  } while (0);
  j = 0x1234;
  k = 0x5678;
  i = (buffer[0] == '*') ? j : k;
  check(i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119d <main+0x3d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    11a2 <main+0x42>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    11da <main+0x7a>
lea    0xe47(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    11df <main+0x7f>
jmp    11e4 <main+0x84>
mov    -0x24(%rbp),%edi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1040 <read@plt>
cmp    $0x4,%eax
je     1214 <main+0xb4>
lea    0xe12(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    1219 <main+0xb9>
movl   $0x1234,-0x1c(%rbp)
movl   $0x5678,-0x20(%rbp)
movsbl -0x14(%rbp),%eax
cmp    $0x2a,%eax
jne    123f <main+0xdf>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1245 <main+0xe5>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <check@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
cmp    $0x2,%edi
jne    11c7 <main+0x67>
mov    0x8(%rsi),%rdi
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
cmp    $0xffffffff,%eax
je     11e0 <main+0x80>
lea    0x14(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <read@plt>
cmp    $0x4,%eax
jne    11e9 <main+0x89>
movl   $0x1234,0x10(%rsp)
movl   $0x5678,0xc(%rsp)
cmpb   $0x2a,0x14(%rsp)
lea    0x10(%rsp),%rax
lea    0xc(%rsp),%rcx
cmove  %rax,%rcx
mov    (%rcx),%edi
call   1070 <check@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    (%rsi),%rsi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
lea    0xe2b(%rip),%rdi
jmp    11f0 <main+0x90>
lea    0xe27(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Usage: %s <file>\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"read\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
br label %20
20: ; preds = %19
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_RDONLY
%25 = call i32 @open(i8* %23, i32 %24)
store i32 %25, i32* %10
%26 = icmp ne i32 %25, -1
br i1 %26, label %30, label %27
27: ; preds = %20
%28 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %20
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
%33 = load i32, i32* %10
%34 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%35 = call i32 @read(i32 %33, i8* %34, i32 4)
%36 = icmp eq i32 %35, 4
br i1 %36, label %40, label %37
37: ; preds = %32
%38 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @exit(i32 -1)
unreachable
40: ; preds = %32
br label %41
41: ; preds = %40
store volatile i32 4660, i32* %8
store volatile i32 22136, i32* %9
%42 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 42
br i1 %45, label %46, label %48
46: ; preds = %41
%47 = load volatile i32, i32* %8
br label %50
48: ; preds = %41
%49 = load volatile i32, i32* %9
br label %50
50: ; preds = %48, %46
%51 = phi i32 [ %47, %46 ], [ %49, %48 ]
store i32 %51, i32* %7
%52 = load i32, i32* %7
%53 = call i32 @check(i32 %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Usage: %s <file>\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"read\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp eq i32 %0, 2
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = load i32, i32* @O_RDONLY
%18 = tail call i32 @open(i8* %16, i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @exit(i32 -1)
unreachable
23: ; preds = %14
%24 = call i32 @read(i32 %18, i8* %6, i32 4)
%25 = icmp eq i32 %24, 4
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = tail call i32 @exit(i32 -1)
unreachable
29: ; preds = %23
store volatile i32 4660, i32* %4
store volatile i32 22136, i32* %5
%30 = load i8, i8* %6
%31 = icmp eq i8 %30, 42
%32 = select i1 %31, i32* %4, i32* %5
%33 = load volatile i32, i32* %32
%34 = tail call i32 @check(i32 %33)
ret i32 0
}