#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 fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  FILE *pFile = NULL;
  pFile = fopen("fputc.txt", "w");
  if (pFile == NULL) {
  } else {
    int result = fputc('T', pFile);
    printf("%x %c\n", result, result);
    fclose(pFile);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xea2(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117e <main+0x3e>
jmp    11aa <main+0x6a>
mov    -0x10(%rbp),%rsi
mov    $0x54,%edi
call   1050 <fputc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1181 <main+0x41>
mov    %rax,%rbx
mov    $0x54,%edi
mov    %rax,%rsi
call   1050 <fputc@plt>
lea    0xe9c(%rip),%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"fputc.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%x %c\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 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 %7, label %3
3: ; preds = %0
%4 = tail call i32 @fputc(i8 signext 84, i32* %1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %4)
%6 = tail call i32 @fclose(i32* %1)
br label %7
7: ; preds = %0, %3
ret i32 0
}