#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*/ STDOUT_FILENO;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ intToStr(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(int argc, char **argv) {
  if (argc < 2) {
    write(STDOUT_FILENO, "A file must be passed!\nusage: show <file>\n", 42);
    exit(1);
  }
  int r = open(argv[1], O_RDONLY);
  if (r == -1) {
    write(STDOUT_FILENO,
          "The specified file could not be opened for reading!\n", 52);
    char error[6];
    intToStr(error, 4325);
    write(STDOUT_FILENO, error, 4);
  }
  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)
jge    1184 <main+0x44>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    $0x2a,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11e6 <main+0xa6>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
mov    $0x34,%edx
call   1030 <write@plt>
lea    -0x1a(%rbp),%rdi
mov    $0x10e5,%esi
call   1050 <intToStr@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    -0x1a(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    11a7 <main+0x67>
mov    0x8(%rsi),%rdi
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
cmp    $0xffffffff,%eax
jne    119d <main+0x5d>
mov    0x2e89(%rip),%r14
mov    (%r14),%edi
lea    0xeba(%rip),%rsi
mov    $0x34,%edx
call   1030 <write@plt>
lea    0x2(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x10e5,%esi
call   1050 <intToStr@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
mov    $0x2a,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@.str = [43 x i8] c"A file must be passed!\0Ausage: show <file>\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [53 x i8] c"The specified file could not be opened for reading!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [6 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @STDOUT_FILENO
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 42)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_RDONLY
%19 = call i32 @open(i8* %17, i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %30
22: ; preds = %14
%23 = load i32, i32* @STDOUT_FILENO
%24 = call i32 @write(i32 %23, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 52)
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%26 = call i32 @intToStr(i8* %25, i32 4325)
%27 = load i32, i32* @STDOUT_FILENO
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%29 = call i32 @write(i32 %27, i8* %28, i32 4)
br label %30
30: ; preds = %22, %14
ret i32 0
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@.str = [43 x i8] c"A file must be passed!\0Ausage: show <file>\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [53 x i8] c"The specified file could not be opened for reading!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [6 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @STDOUT_FILENO
%7 = tail call i32 @write(i32 %6, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 42)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @O_RDONLY
%13 = tail call i32 @open(i8* %11, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %22
15: ; preds = %9
%16 = load i32, i32* @STDOUT_FILENO
%17 = tail call i32 @write(i32 %16, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 52)
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%19 = call i32 @intToStr(i8* %18, i32 4325)
%20 = load i32, i32* @STDOUT_FILENO
%21 = call i32 @write(i32 %20, i8* %18, i32 4)
br label %22
22: ; preds = %15, %9
ret i32 0
}