#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 st_mode;
  int st_size;
};

/* Variables and functions */
int /*<<< orphan*/ memset(struct stat *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int stat(char *, struct stat *);
int main(int argc, char **argv) {
  struct stat st;
  int r;
  memset(&st, 0, sizeof st);
  r = stat(argv[1], &st);
  if (r < 0)
    return 1;
  printf("mode %08x\n", st.st_mode);
  printf("size %08lx\n", st.st_size);
  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)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1180 <main+0x50>
movl   $0x1,-0x4(%rbp)
jmp    11a5 <main+0x75>
mov    -0x18(%rbp),%esi
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe72(%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   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0x8(%rsp),%rbp
xor    %r14d,%r14d
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x8(%rbx),%rdi
mov    %rbp,%rsi
call   1050 <stat@plt>
test   %eax,%eax
js     1184 <main+0x54>
mov    0x8(%rsp),%esi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
jmp    118a <main+0x5a>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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