#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*/ st_size;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct stat sb;
  int ret;
  if (argc < 2) {
    fprintf(stderr, "usage: %s <file> \n", argv[0]);
    return -1;
  }
  ret = stat(argv[1], &sb);
  if (ret == -1) {
    perror("stat");
    return -1;
  }
  printf("%s is %ld bytes!\n", argv[1], sb.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)
cmpl   $0x2,-0x8(%rbp)
jge    1188 <main+0x48>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dc <main+0x9c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11be <main+0x7e>
lea    0xe66(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dc <main+0x9c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%edx
lea    0xe48(%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
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     116c <main+0x2c>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xea0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    1195 <main+0x55>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
je     119b <main+0x5b>
mov    0x8(%rbx),%rsi
mov    0x8(%rsp),%edx
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe71(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%eax
jmp    1195 <main+0x55>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [19 x i8] c"usage: %s <file> \0A\00"
@.str.1 = [5 x i8] c"stat\00"
@.str.2 = [18 x i8] c"%s is %ld bytes!\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 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 -1, i32* %3
br label %32
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @stat(i8* %19, %struct.stat* %6)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %32
25: ; preds = %16
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%30 = load i32, i32* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %28, i32 %30)
store i32 0, i32* %3
br label %32
32: ; preds = %25, %23, %10
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [19 x i8] c"usage: %s <file> \0A\00"
@.str.1 = [5 x i8] c"stat\00"
@.str.2 = [18 x i8] c"%s is %ld bytes!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %22
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @stat(i8* %12, %struct.stat* %3)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %22
17: ; preds = %10
%18 = load i8*, i8** %11
%19 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%20 = load i32, i32* %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %18, i32 %20)
br label %22
22: ; preds = %17, %15, %6
%23 = phi i32 [ -1, %6 ], [ -1, %15 ], [ 0, %17 ]
ret i32 %23
}