#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 */
scalar_t__ mkdir(char *, int);
scalar_t__ mount(char *, char *, char *, int /*<<< orphan*/,
                 int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int main() {
  if (mkdir("/mnt", 0777)) {
    perror("mkdir");
    return 1;
  }
  if (mount("/dev/hdb1", "/mnt", "ext2", 0, 0)) {
    perror("mount");
    return 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
je     1172 <main+0x42>
lea    0xea4(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11bb <main+0x8b>
lea    0xe92(%rip),%rdi
lea    0xe80(%rip),%rsi
lea    0xe8e(%rip),%rdx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1040 <mount@plt>
cmp    $0x0,%rax
je     11b4 <main+0x84>
lea    0xe77(%rip),%rdi
call   1050 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    11bb <main+0x8b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
test   %rax,%rax
jne    1171 <main+0x41>
lea    0xebd(%rip),%rdi
lea    0xeab(%rip),%rsi
lea    0xeb9(%rip),%rdx
xor    %ebx,%ebx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %rax,%rax
jne    117f <main+0x4f>
mov    %ebx,%eax
pop    %rbx
ret
mov    $0x1,%ebx
lea    0xe88(%rip),%rdi
jmp    118b <main+0x5b>
mov    $0x2,%ebx
lea    0xe8f(%rip),%rdi
call   1050 <perror@plt>
jmp    116d <main+0x3d>

LLVM IR (-O0):
@.str = [5 x i8] c"/mnt\00"
@.str.1 = [6 x i8] c"mkdir\00"
@.str.2 = [10 x i8] c"/dev/hdb1\00"
@.str.3 = [5 x i8] c"ext2\00"
@.str.4 = [6 x i8] c"mount\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 511)
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %12
6: ; preds = %0
%7 = call i64 @mount(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %1
br label %12
11: ; preds = %6
store i32 0, i32* %1
br label %12
12: ; preds = %11, %9, %4
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@.str = [5 x i8] c"/mnt\00"
@.str.1 = [6 x i8] c"mkdir\00"
@.str.2 = [10 x i8] c"/dev/hdb1\00"
@.str.3 = [5 x i8] c"ext2\00"
@.str.4 = [6 x i8] c"mount\00"
define i32 @main() {
%1 = tail call i64 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 511)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i64 @mount(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3, %0
%7 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %0 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %3 ]
%8 = phi i32 [ 1, %0 ], [ 2, %3 ]
%9 = tail call i32 @perror(i8* %7)
br label %10
10: ; preds = %6, %3
%11 = phi i32 [ 0, %3 ], [ %8, %6 ]
ret i32 %11
}