#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 */
struct stat {
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ buf_handler(struct stat *);
int /*<<< orphan*/ perror(char *);
scalar_t__ stat(char *, struct stat *);
int main(int argc, char **argv) {
  assert(argc > 1);
  struct stat buf = {0};
  if (stat(argv[1], &buf) < 0) {
    perror("stat");
    goto err;
  }
  buf_handler(&buf);
  return 0;
err:
  return -1;
}


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   $0x1,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0x0,%rax
jge    11b3 <main+0x63>
lea    0xe57(%rip),%rdi
call   1070 <perror@plt>
jmp    11c8 <main+0x78>
lea    -0x18(%rbp),%rdi
call   1050 <buf_handler@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cf <main+0x7f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
xor    %eax,%eax
cmp    $0x2,%edi
setge  %al
mov    %eax,%edi
call   1030 <assert@plt>
movl   $0x0,0x8(%rsp)
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1050 <stat@plt>
test   %rax,%rax
js     1184 <main+0x44>
lea    0x8(%rsp),%rdi
call   1040 <buf_handler@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe75(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%eax
jmp    117e <main+0x3e>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [5 x i8] c"stat\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = bitcast %struct.stat* %6 to i8*
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @stat(i8* %14, %struct.stat* %6)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %21
19: ; preds = %2
%20 = call i32 @buf_handler(%struct.stat* %6)
store i32 0, i32* %3
br label %22
21: ; preds = %17
store i32 -1, i32* %3
br label %22
22: ; preds = %21, %19
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [5 x i8] c"stat\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = icmp sgt i32 %0, 1
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = bitcast %struct.stat* %3 to i8*
%8 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
store i32 0, i32* %8
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i64 @stat(i8* %10, %struct.stat* %3)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %17
15: ; preds = %2
%16 = call i32 @buf_handler(%struct.stat* %3)
br label %17
17: ; preds = %13, %15
%18 = phi i32 [ -1, %13 ], [ 0, %15 ]
ret i32 %18
}