#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
int main02(void) {
  FILE *p = fopen("D:\\temp\\a.txt", "w");
  if (p == NULL) {
    printf("error\n");
  } else {
    putc('a', p);
    putc('b', p);
    putc('c', p);
    fclose(p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main02>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    117b <main02+0x3b>
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
jmp    11ae <main02+0x6e>
mov    -0x8(%rbp),%rsi
mov    $0x61,%edi
call   1050 <putc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x62,%edi
call   1050 <putc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x63,%edi
call   1050 <putc@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main02>:
push   %rbx
lea    0xeb8(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     118d <main02+0x4d>
mov    %rax,%rbx
mov    $0x61,%edi
mov    %rax,%rsi
call   1050 <putc@plt>
mov    $0x62,%edi
mov    %rbx,%rsi
call   1050 <putc@plt>
mov    $0x63,%edi
mov    %rbx,%rsi
call   1050 <putc@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1199 <main02+0x59>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"D:\\temp\\a.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"error\0A\00"
define i32 @main02() {
%1 = alloca i32*
%2 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %2, i32** %1
%3 = load i32*, i32** %1
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %16
7: ; preds = %0
%8 = load i32*, i32** %1
%9 = call i32 @putc(i8 signext 97, i32* %8)
%10 = load i32*, i32** %1
%11 = call i32 @putc(i8 signext 98, i32* %10)
%12 = load i32*, i32** %1
%13 = call i32 @putc(i8 signext 99, i32* %12)
%14 = load i32*, i32** %1
%15 = call i32 @fclose(i32* %14)
br label %16
16: ; preds = %7, %5
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"D:\\temp\\a.txt\00"
@.str.1 = [2 x i8] c"w\00"
@str = [6 x i8] c"error\00"
define i32 @main02() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %10
5: ; preds = %0
%6 = tail call i32 @putc(i8 signext 97, i32* %1)
%7 = tail call i32 @putc(i8 signext 98, i32* %1)
%8 = tail call i32 @putc(i8 signext 99, i32* %1)
%9 = tail call i32 @fclose(i32* %1)
br label %10
10: ; preds = %5, %3
ret i32 0
}