#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ mkdir(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *f = fopen("/tmp/out.txt", "wb");
  if (f != NULL) {
    fprintf(stderr, "File creation should have failed\n");
    return 1;
  }
  if (mkdir("/tmp/foobar") == 0) {
    fprintf(stderr, "Directory creation should have failed\n");
    return 1;
  }
  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)
lea    0xeb3(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1189 <main+0x59>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <main+0x97>
lea    0xea2(%rip),%rdi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
jne    11c0 <main+0x90>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <main+0x97>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0xece(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1165 <main+0x35>
lea    0xec0(%rip),%rsi
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    117b <main+0x4b>
lea    0xec6(%rip),%rdi
call   1030 <mkdir@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     117d <main+0x4d>
pop    %rcx
ret
lea    0xeba(%rip),%rsi
jmp    1150 <main+0x20>

LLVM IR (-O0):
@.str = [13 x i8] c"/tmp/out.txt\00"
@.str.1 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.2 = [34 x i8] c"File creation should have failed\0A\00"
@.str.3 = [12 x i8] c"/tmp/foobar\00"
@.str.4 = [39 x i8] c"Directory creation should have failed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %20
13: ; preds = %2
%14 = call i64 @mkdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %20
19: ; preds = %13
store i32 0, i32* %3
br label %20
20: ; preds = %19, %16, %10
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [13 x i8] c"/tmp/out.txt\00"
@.str.1 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.2 = [34 x i8] c"File creation should have failed\0A\00"
@.str.3 = [12 x i8] c"/tmp/foobar\00"
@.str.4 = [39 x i8] c"Directory creation should have failed\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i64 @mkdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5, %2
%9 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), %5 ]
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* %9)
br label %12
12: ; preds = %8, %5
%13 = phi i32 [ 0, %5 ], [ 1, %8 ]
ret i32 %13
}