#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*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
int ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned long);
long longval();
unsigned long ulongval();
int main() {
  FILE *f = fopen("conftest.val", "w");
  if (!f)
    exit(1);
  if (((long)(sizeof(size_t))) < 0) {
    long i = longval();
    if (i != ((long)(sizeof(size_t))))
      exit(1);
    fprintf(f, "%ld\n", i);
  } else {
    unsigned long i = ulongval();
    if (i != ((long)(sizeof(size_t))))
      exit(1);
    fprintf(f, "%lu\n", i);
  }
  exit(ferror(f) | fclose(f) != 0);
  ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119b <main+0x3b>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   1030 <ulongval@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x8,-0x18(%rbp)
je     11bb <main+0x5b>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe45(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <ferror@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x1c(%rbp),%edi
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
or     %eax,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c1 <main+0x61>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <ulongval@plt>
cmp    $0x8,%rax
jne    11c1 <main+0x61>
lea    0xe7d(%rip),%rsi
mov    $0x8,%edx
mov    %rbx,%rdi
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <ferror@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
or     %ebp,%edi
call   1080 <exit@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"conftest.val\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"%lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 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 ne i32* %5, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i64 (...) @ulongval()
store i64 %10, i64* %3
%11 = load i64, i64* %3
%12 = icmp ne i64 %11, 8
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %9
%16 = load i32*, i32** %2
%17 = load i64, i64* %3
%18 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %17)
%19 = load i32*, i32** %2
%20 = call i32 @ferror(i32* %19)
%21 = load i32*, i32** %2
%22 = call i64 @fclose(i32* %21)
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i32
%25 = or i32 %20, %24
%26 = call i32 @exit(i32 %25)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"conftest.val\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [5 x i8] c"%lu\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 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 @exit(i32 1)
unreachable
5: ; preds = %0
%6 = tail call i64 (...) @ulongval()
%7 = icmp eq i64 %6, 8
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %5
%11 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 8)
%12 = tail call i32 @ferror(i32* %1)
%13 = tail call i64 @fclose(i32* %1)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
%16 = or i32 %12, %15
%17 = tail call i32 @exit(i32 %16)
unreachable
}