#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*/ ENOENT;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  switch (argc) {
  case 1:
    break;
  case 2: {
    FILE *fp = fopen(argv[1], "r");
    if (!fp) {
      if (errno == ENOENT)
        break;
      perror(argv[1]);
      exit(2);
    }
    char buf;
    int rc = fread(&buf, 1, 1, fp);
    if (rc) {
      fprintf(stderr, "Syntax error: Unexpected statement\n");
      exit(1);
    }
    fclose(fp);
    break;
  }
  }
  puts("Hello World!");
  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)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x1,%eax
je     11ab <main+0x3b>
jmp    119a <main+0x2a>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
je     11b0 <main+0x40>
jmp    1250 <main+0xe0>
jmp    1250 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe41(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1207 <main+0x97>
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
mov    0x2de5(%rip),%rcx
cmp    (%rcx),%eax
jne    11f0 <main+0x80>
jmp    1250 <main+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <perror@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rcx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1247 <main+0xd7>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xdcf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11cd <main+0x5d>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe79(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b9 <main+0x49>
mov    %rax,%rbx
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
test   %eax,%eax
jne    11e3 <main+0x73>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    11cd <main+0x5d>
mov    0x2e18(%rip),%rax
mov    (%rax),%eax
mov    0x2dff(%rip),%rcx
cmp    (%rcx),%eax
jne    1202 <main+0x92>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe0f(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x8(%r14),%rdi
call   1080 <perror@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@errno = global i32 0
@ENOENT = global i32 0
@stderr = global i32 0
@.str.1 = [36 x i8] c"Syntax error: Unexpected statement\0A\00"
@.str.2 = [13 x i8] c"Hello World!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
switch i32 %9, label %41 [
i32 1, label %10
i32 2, label %11
]
10: ; preds = %2
br label %41
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %6
%16 = load i32*, i32** %6
%17 = icmp ne i32* %16, null
br i1 %17, label %29, label %18
18: ; preds = %11
%19 = load i32, i32* @errno
%20 = load i32, i32* @ENOENT
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %18
br label %41
23: ; preds = %18
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @perror(i8* %26)
%28 = call i32 @exit(i32 2)
unreachable
29: ; preds = %11
%30 = load i32*, i32** %6
%31 = call i32 @fread(i8* %7, i32 1, i32 1, i32* %30)
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %29
%39 = load i32*, i32** %6
%40 = call i32 @fclose(i32* %39)
br label %41
41: ; preds = %2, %38, %22, %10
%42 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@errno = global i32 0
@ENOENT = global i32 0
@stderr = global i32 0
@.str.1 = [36 x i8] c"Syntax error: Unexpected statement\0A\00"
@.str.2 = [13 x i8] c"Hello World!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %27
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %18
10: ; preds = %5
%11 = load i32, i32* @errno
%12 = load i32, i32* @ENOENT
%13 = icmp eq i32 %11, %12
br i1 %13, label %27, label %14
14: ; preds = %10
%15 = load i8*, i8** %6
%16 = tail call i32 @perror(i8* %15)
%17 = tail call i32 @exit(i32 2)
unreachable
18: ; preds = %5
%19 = call i32 @fread(i8* %3, i32 1, i32 1, i32* %8)
%20 = icmp eq i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %18
%26 = tail call i32 @fclose(i32* %8)
br label %27
27: ; preds = %25, %10, %2
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}