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

/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ errno;
scalar_t__ ferror(int /*<<< orphan*/);
int fwrite(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strtoul(char *, char **, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  uint8_t value = 0;
  if (argc >= 2) {
    char *end;
    value = strtoul(argv[1], &end, 0);
    if (*end != '\0') {
      errno = EINVAL;
      perror(argv[1]);
      return 1;
    }
  }
  while (!0) {
    if (fwrite(&value, sizeof(value), 1, stdout) == 1) {
    } else if (ferror(stdout)) {
      perror("fwrite");
      return 1;
    } else {
      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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11bd <main+0x7d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b8 <main+0x78>
mov    0x2e44(%rip),%rax
mov    (%rax),%ecx
mov    0x2e43(%rip),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    122d <main+0xed>
jmp    11bd <main+0x7d>
jmp    11c2 <main+0x82>
mov    0x2e07(%rip),%rax
mov    (%rax),%ecx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
cmp    $0x1,%eax
jne    11ec <main+0xac>
jmp    1228 <main+0xe8>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     121c <main+0xdc>
lea    0xdf5(%rip),%rdi
call   1040 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    122d <main+0xed>
movl   $0x0,-0x4(%rbp)
jmp    122d <main+0xed>
jmp    11c2 <main+0x82>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x4(%rsp)
cmp    $0x1,%edi
jle    1180 <main+0x40>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %eax,0x4(%rsp)
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
jne    11c2 <main+0x82>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x2e49(%rip),%rbx
mov    (%rbx),%ecx
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
cmp    $0x1,%eax
je     1180 <main+0x40>
mov    (%rbx),%edi
call   1030 <ferror@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11b9 <main+0x79>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe40(%rip),%rdi
jmp    11d8 <main+0x98>
mov    0x2e0f(%rip),%rax
mov    (%rax),%eax
mov    0x2e0e(%rip),%rcx
mov    %eax,(%rcx)
mov    0x8(%rbx),%rdi
call   1040 <perror@plt>
mov    $0x1,%eax
jmp    11b3 <main+0x73>

LLVM IR (-O0):
@EINVAL = global i32 0
@errno = global i32 0
@stdout = global i32 0
@.str = [7 x i8] c"fwrite\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 2
br i1 %9, label %10, label %26
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strtoul(i8* %13, i8** %7, i32 0)
store i32 %14, i32* %6
%15 = load i8*, i8** %7
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %10
%20 = load i32, i32* @EINVAL
store i32 %20, i32* @errno
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @perror(i8* %23)
store i32 1, i32* %3
br label %40
25: ; preds = %10
br label %26
26: ; preds = %25, %2
br label %27
27: ; preds = %26, %39
%28 = load i32, i32* @stdout
%29 = call i32 @fwrite(i32* %6, i32 4, i32 1, i32 %28)
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %32
31: ; preds = %27
br label %39
32: ; preds = %27
%33 = load i32, i32* @stdout
%34 = call i64 @ferror(i32 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %40
38: ; preds = %32
store i32 0, i32* %3
br label %40
39: ; preds = %31
br label %27
40: ; preds = %38, %36, %19
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@EINVAL = global i32 0
@errno = global i32 0
@stdout = global i32 0
@.str = [7 x i8] c"fwrite\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = icmp sgt i32 %0, 1
br i1 %6, label %8, label %7
7: ; preds = %16, %2
br label %21
8: ; preds = %2
%9 = bitcast i8** %4 to i8*
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strtoul(i8* %11, i8** %4, i32 0)
store i32 %12, i32* %3
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %8
br label %7
17: ; preds = %8
%18 = load i32, i32* @EINVAL
store i32 %18, i32* @errno
%19 = load i8*, i8** %10
%20 = tail call i32 @perror(i8* %19)
br label %31
21: ; preds = %7, %21
%22 = load i32, i32* @stdout
%23 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32 %22)
%24 = icmp eq i32 %23, 1
br i1 %24, label %21, label %25
25: ; preds = %21
%26 = load i32, i32* @stdout
%27 = call i64 @ferror(i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %17, %25, %29
%32 = phi i32 [ 1, %29 ], [ 1, %17 ], [ 0, %25 ]
ret i32 %32
}