#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 {
  scalar_t__ st_blksize;
  scalar_t__ st_blocks;
  scalar_t__ st_size;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int lstat(char *, struct stat *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct stat sb;
  if (argc != 2) {
    fprintf(stderr, "usage: %s file\n", argv[0]);
    exit(1);
  }
  if (lstat(argv[1], &sb) == -1) {
    fprintf(stderr, "Can't stat %s: %s\n", argv[1], strerror(errno));
    exit(1);
  }
  printf("st_size   : %d\n", (int)sb.st_size);
  printf("st_blocks : %d\n", (int)sb.st_blocks);
  printf("st_blksize: %d\n", (int)sb.st_blksize);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1198 <main+0x48>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <lstat@plt>
cmp    $0xffffffff,%eax
jne    11fa <main+0xaa>
mov    0x2e27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%esi
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
lea    0xe18(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11aa <main+0x5a>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   1040 <lstat@plt>
cmp    $0xffffffff,%eax
jne    11ce <main+0x7e>
mov    0x2e6a(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rbx),%rbx
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe7f(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe43(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x10(%rsp),%esi
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
mov    (%rsp),%esi
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i64, i64, i64 }
@stderr = global i32 0
@.str = [16 x i8] c"usage: %s file\0A\00"
@.str.1 = [19 x i8] c"Can't stat %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [16 x i8] c"st_size : %d\0A\00"
@.str.3 = [16 x i8] c"st_blocks : %d\0A\00"
@.str.4 = [16 x i8] c"st_blksize: %d\0A\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 ne i32 %7, 2
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @lstat(i8* %19, %struct.stat* %6)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %31
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %26, i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %16
%32 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%33 = load i64, i64* %32
%34 = trunc i64 %33 to i32
%35 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%37 = load i64, i64* %36
%38 = trunc i64 %37 to i32
%39 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%41 = load i64, i64* %40
%42 = trunc i64 %41 to i32
%43 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i64, i64, i64 }
@stderr = global i32 0
@.str = [16 x i8] c"usage: %s file\0A\00"
@.str.1 = [19 x i8] c"Can't stat %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [16 x i8] c"st_size : %d\0A\00"
@.str.3 = [16 x i8] c"st_blocks : %d\0A\00"
@.str.4 = [16 x i8] c"st_blksize: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @lstat(i8* %13, %struct.stat* %3)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %12
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %20)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %11
%24 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
%25 = load i64, i64* %24
%26 = trunc i64 %25 to i32
%27 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%29 = load i64, i64* %28
%30 = trunc i64 %29 to i32
%31 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%33 = load i64, i64* %32
%34 = trunc i64 %33 to i32
%35 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = tail call i32 @exit(i32 0)
unreachable
}