#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__ mount(char const *, char const *, char const *, int /*<<< orphan*/,
                 int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char const *, char const *, char const *);
int mount_fs(const char *fstype, const char *device, const char *mountpoint) {
  printf("mounting %s %s %s\n", fstype, device, mountpoint);
  if (mount(device, mountpoint, fstype, 0, NULL) == 0) {
    return 0;
  }
  perror("mount failed");
  return -1;
}


x86 assembly (clang, -O0):
<mount_fs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <mount@plt>
cmp    $0x0,%rax
jne    118a <mount_fs+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    119d <mount_fs+0x6d>
lea    0xe82(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mount_fs>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
lea    0xeb8(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1040 <printf@plt>
xor    %r14d,%r14d
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <mount@plt>
test   %rax,%rax
jne    1180 <mount_fs+0x50>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe8c(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%r14d
jmp    1171 <mount_fs+0x41>

LLVM IR (-O0):
@.str = [19 x i8] c"mounting %s %s %s\0A\00"
@.str.1 = [13 x i8] c"mount failed\00"
define i32 @mount_fs(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i8*, i8** %5
%9 = load i8*, i8** %6
%10 = load i8*, i8** %7
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9, i8* %10)
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = load i8*, i8** %5
%15 = call i64 @mount(i8* %12, i8* %13, i8* %14, i32 0, i32* null)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %3
store i32 0, i32* %4
br label %20
18: ; preds = %3
%19 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %20
20: ; preds = %18, %17
%21 = load i32, i32* %4
ret i32 %21
}

LLVM IR (-O2):
@.str = [19 x i8] c"mounting %s %s %s\0A\00"
@.str.1 = [13 x i8] c"mount failed\00"
define i32 @mount_fs(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %2)
%5 = tail call i64 @mount(i8* %1, i8* %2, i8* %0, i32 0, i32* null)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %3, %7
%10 = phi i32 [ -1, %7 ], [ 0, %3 ]
ret i32 %10
}