#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 fnode {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fatfs_close(struct fnode *);
int /*<<< orphan*/ printf(char *, ...);
struct fnode *vfs_open(char *, int);
int touch(char *path) {
  if (!path)
    return -1;
  printf("C:\\TOUCH %s\n", path);
  struct fnode *fno = vfs_open(path, 0x00);
  if (fno)
    fatfs_close(fno);
  else
    printf("NO FNO!\n");
  return 0;
}


x86 assembly (clang, -O0):
<touch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1153 <touch+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a2 <touch+0x72>
mov    -0x10(%rbp),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1050 <vfs_open@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118d <touch+0x5d>
mov    -0x18(%rbp),%rdi
call   1040 <fatfs_close@plt>
jmp    119b <touch+0x6b>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<touch>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1177 <touch+0x37>
mov    %rdi,%rbx
lea    0xeae(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <vfs_open@plt>
test   %rax,%rax
je     117e <touch+0x3e>
mov    %rax,%rdi
call   1050 <fatfs_close@plt>
jmp    118a <touch+0x4a>
mov    $0xffffffff,%ebp
jmp    118a <touch+0x4a>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.fnode = type { i32 }
@.str = [13 x i8] c"C:\\TOUCH %s\0A\00"
@.str.1 = [9 x i8] c"NO FNO!\0A\00"
define i32 @touch(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.fnode*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 -1, i32* %2
br label %21
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %3
%12 = call %struct.fnode* @vfs_open(i8* %11, i32 0)
store %struct.fnode* %12, %struct.fnode** %4
%13 = load %struct.fnode*, %struct.fnode** %4
%14 = icmp ne %struct.fnode* %13, null
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = load %struct.fnode*, %struct.fnode** %4
%17 = call i32 @fatfs_close(%struct.fnode* %16)
br label %20
18: ; preds = %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
store i32 0, i32* %2
br label %21
21: ; preds = %20, %7
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
%struct.fnode = type { i32 }
@.str = [13 x i8] c"C:\\TOUCH %s\0A\00"
@str = [8 x i8] c"NO FNO!\00"
define i32 @touch(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call %struct.fnode* @vfs_open(i8* %0, i32 0)
%6 = icmp eq %struct.fnode* %5, null
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 @fatfs_close(%struct.fnode* %5)
br label %11
9: ; preds = %3
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %7, %9, %1
%12 = phi i32 [ -1, %1 ], [ 0, %9 ], [ 0, %7 ]
ret i32 %12
}