#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*/ close(int);
int /*<<< orphan*/ disp_file(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  int fd;
  if (argc != 2) {
    if (argc > 2)
      write(2, "Too many arguments.\n", 20);
    if (argc < 2)
      write(2, "File name missing.\n", 19);
    return (1);
  }
  fd = open(argv[1], O_RDONLY);
  disp_file(fd);
  close(fd);
  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)
cmpl   $0x2,-0x8(%rbp)
je     11ac <main+0x6c>
cmpl   $0x2,-0x8(%rbp)
jle    1180 <main+0x40>
mov    $0x2,%edi
lea    0xe8a(%rip),%rsi
mov    $0x14,%edx
call   1040 <write@plt>
cmpl   $0x2,-0x8(%rbp)
jge    11a0 <main+0x60>
mov    $0x2,%edi
lea    0xe7f(%rip),%rsi
mov    $0x13,%edx
call   1040 <write@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dc <main+0x9c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <disp_file@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    116c <main+0x2c>
mov    0x8(%rsi),%rdi
mov    0x2e97(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <disp_file@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
pop    %rbx
ret
jle    1181 <main+0x41>
lea    0xe8b(%rip),%rsi
mov    $0x2,%edi
mov    $0x14,%edx
jmp    1192 <main+0x52>
lea    0xe8d(%rip),%rsi
mov    $0x2,%edi
mov    $0x13,%edx
call   1040 <write@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Too many arguments.\0A\00"
@.str.1 = [20 x i8] c"File name missing.\0A\00"
@O_RDONLY = global i32 0
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
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %20
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @write(i32 2, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 20)
br label %14
14: ; preds = %12, %9
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @write(i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 19)
br label %19
19: ; preds = %17, %14
store i32 1, i32* %3
br label %30
20: ; preds = %2
%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* %6
%26 = load i32, i32* %6
%27 = call i32 @disp_file(i32 %26)
%28 = load i32, i32* %6
%29 = call i32 @close(i32 %28)
store i32 0, i32* %3
br label %30
30: ; preds = %20, %19
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [21 x i8] c"Too many arguments.\0A\00"
@.str.1 = [20 x i8] c"File name missing.\0A\00"
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 20)
br label %17
8: ; preds = %4
%9 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 19)
br label %17
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDONLY
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = tail call i32 @disp_file(i32 %14)
%16 = tail call i32 @close(i32 %14)
br label %17
17: ; preds = %6, %8, %10
%18 = phi i32 [ 0, %10 ], [ 1, %8 ], [ 1, %6 ]
ret i32 %18
}