#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_RDWR;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ print_usage(char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  int fd;
  if (argc != 2) {
    print_usage(argv[0]);
    return 0;
  }
  fd = open(argv[1], O_RDWR);
  if (fd < 0)
    printf("can't open %s\n", argv[1]);
  else
    printf("can open %s\n", argv[1]);
  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     1168 <main+0x38>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bf <main+0x8f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11a4 <main+0x74>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
jmp    11b8 <main+0x88>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    115c <main+0x2c>
mov    0x8(%rbx),%rdi
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    0x8(%rbx),%rsi
test   %eax,%eax
js     1166 <main+0x36>
lea    0xeb5(%rip),%rdi
jmp    116d <main+0x3d>
mov    (%rbx),%rdi
call   1050 <print_usage@plt>
jmp    1172 <main+0x42>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@O_RDWR = global i32 0
@.str = [15 x i8] c"can't open %s\0A\00"
@.str.1 = [13 x i8] c"can open %s\0A\00"
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 %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @print_usage(i8* %12)
store i32 0, i32* %3
br label %33
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_RDWR
%19 = call i32 @open(i8* %17, i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %14
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %32
27: ; preds = %14
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %27, %22
store i32 0, i32* %3
br label %33
33: ; preds = %32, %9
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@.str = [15 x i8] c"can't open %s\0A\00"
@.str.1 = [13 x i8] c"can open %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @print_usage(i8* %5)
br label %18
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @O_RDWR
%11 = tail call i32 @open(i8* %9, i32 %10)
%12 = icmp slt i32 %11, 0
%13 = load i8*, i8** %8
br i1 %12, label %14, label %16
14: ; preds = %7
%15 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %18
16: ; preds = %7
%17 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %18
18: ; preds = %14, %16, %4
ret i32 0
}