#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 */

/* Variables and functions */
unsigned char daa(unsigned char, unsigned char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
int main() {
  unsigned char r;
  int count = 0;
  unsigned char a = 0;
  unsigned char cc = 0;
  fprintf(stdout, "Carry: 0, Halfcarry: o\n");
  for (count = 0; count < 256; count++) {
    cc = 0;
    r = daa(a, &cc);
    fprintf(stdout, "%02X%02X ", r, cc);
    a += 1;
  }
  fprintf(stdout, "Carry: 1, Halfcarry: o\n");
  for (count = 0; count < 256; count++) {
    cc = 1;
    r = daa(a, &cc);
    fprintf(stdout, "%02X%02X ", r, cc);
    a += 1;
  }
  fprintf(stdout, "Carry: 0, Halfcarry: 1\n");
  for (count = 0; count < 256; count++) {
    cc = 0x20;
    r = daa(a, &cc);
    fprintf(stdout, "%02X%02X ", r, cc);
    a += 1;
  }
  fprintf(stdout, "Carry: 1, Halfcarry: 1\n");
  for (count = 0; count < 256; count++) {
    cc = 0x21;
    r = daa(a, &cc);
    fprintf(stdout, "%02X%02X ", r, cc);
    a += 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movb   $0x0,-0xd(%rbp)
movb   $0x0,-0xe(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%edi
lea    0xeb2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jge    11b4 <main+0x94>
movb   $0x0,-0xe(%rbp)
lea    -0xe(%rbp),%rsi
movzbl -0xd(%rbp),%edi
call   1040 <daa@plt>
mov    %al,-0x5(%rbp)
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
movzbl -0x5(%rbp),%edx
movzbl -0xe(%rbp),%ecx
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movzbl -0xd(%rbp),%eax
add    $0x1,%eax
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115c <main+0x3c>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jge    122a <main+0x10a>
movb   $0x1,-0xe(%rbp)
lea    -0xe(%rbp),%rsi
movzbl -0xd(%rbp),%edi
call   1040 <daa@plt>
mov    %al,-0x5(%rbp)
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
movzbl -0x5(%rbp),%edx
movzbl -0xe(%rbp),%ecx
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movzbl -0xd(%rbp),%eax
add    $0x1,%eax
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d2 <main+0xb2>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jge    12a0 <main+0x180>
movb   $0x20,-0xe(%rbp)
lea    -0xe(%rbp),%rsi
movzbl -0xd(%rbp),%edi
call   1040 <daa@plt>
mov    %al,-0x5(%rbp)
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
movzbl -0x5(%rbp),%edx
movzbl -0xe(%rbp),%ecx
lea    0xd97(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movzbl -0xd(%rbp),%eax
add    $0x1,%eax
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1248 <main+0x128>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
lea    0xda2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jge    1316 <main+0x1f6>
movb   $0x21,-0xe(%rbp)
lea    -0xe(%rbp),%rsi
movzbl -0xd(%rbp),%edi
call   1040 <daa@plt>
mov    %al,-0x5(%rbp)
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
movzbl -0x5(%rbp),%edx
movzbl -0xe(%rbp),%ecx
lea    0xd21(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movzbl -0xd(%rbp),%eax
add    $0x1,%eax
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12be <main+0x19e>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2eb2(%rip),%rbx
mov    (%rbx),%edi
lea    0xec9(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x7(%rsp),%r14
lea    0xece(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
movb   $0x0,0x7(%rsp)
movzbl %bpl,%edi
mov    %r14,%rsi
call   1040 <daa@plt>
mov    (%rbx),%edi
movzbl %al,%edx
movzbl 0x7(%rsp),%ecx
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    1150 <main+0x30>
mov    (%rbx),%edi
lea    0xe99(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x7(%rsp),%r14
lea    0xe7c(%rip),%r15
xor    %ebp,%ebp
xchg   %ax,%ax
movb   $0x1,0x7(%rsp)
movzbl %bpl,%edi
mov    %r14,%rsi
call   1040 <daa@plt>
mov    (%rbx),%edi
movzbl %al,%edx
movzbl 0x7(%rsp),%ecx
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    11a0 <main+0x80>
mov    (%rbx),%edi
lea    0xe61(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x7(%rsp),%r14
lea    0xe2c(%rip),%r15
xor    %ebp,%ebp
xchg   %ax,%ax
movb   $0x20,0x7(%rsp)
movzbl %bpl,%edi
mov    %r14,%rsi
call   1040 <daa@plt>
mov    (%rbx),%edi
movzbl %al,%edx
movzbl 0x7(%rsp),%ecx
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    11f0 <main+0xd0>
mov    (%rbx),%edi
lea    0xe29(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x7(%rsp),%r14
lea    0xddc(%rip),%r15
xor    %ebp,%ebp
xchg   %ax,%ax
movb   $0x21,0x7(%rsp)
movzbl %bpl,%edi
mov    %r14,%rsi
call   1040 <daa@plt>
mov    (%rbx),%edi
movzbl %al,%edx
movzbl 0x7(%rsp),%ecx
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    1240 <main+0x120>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [24 x i8] c"Carry: 0, Halfcarry: o\0A\00"
@.str.1 = [10 x i8] c"%02X%02X \00"
@.str.2 = [24 x i8] c"Carry: 1, Halfcarry: o\0A\00"
@.str.3 = [24 x i8] c"Carry: 0, Halfcarry: 1\0A\00"
@.str.4 = [24 x i8] c"Carry: 1, Halfcarry: 1\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %3
store i8 0, i8* %4
store i8 0, i8* %5
%6 = load i32, i32* @stdout
%7 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %8
8: ; preds = %24, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 256
br i1 %10, label %11, label %27
11: ; preds = %8
store i8 0, i8* %5
%12 = load i8, i8* %4
%13 = call zeroext i8 @daa(i8 zeroext %12, i8* %5)
store i8 %13, i8* %2
%14 = load i32, i32* @stdout
%15 = load i8, i8* %2
%16 = zext i8 %15 to i32
%17 = load i8, i8* %5
%18 = zext i8 %17 to i32
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %18)
%20 = load i8, i8* %4
%21 = zext i8 %20 to i32
%22 = add nsw i32 %21, 1
%23 = trunc i32 %22 to i8
store i8 %23, i8* %4
br label %24
24: ; preds = %11
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %8
27: ; preds = %8
%28 = load i32, i32* @stdout
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %30
30: ; preds = %46, %27
%31 = load i32, i32* %3
%32 = icmp slt i32 %31, 256
br i1 %32, label %33, label %49
33: ; preds = %30
store i8 1, i8* %5
%34 = load i8, i8* %4
%35 = call zeroext i8 @daa(i8 zeroext %34, i8* %5)
store i8 %35, i8* %2
%36 = load i32, i32* @stdout
%37 = load i8, i8* %2
%38 = zext i8 %37 to i32
%39 = load i8, i8* %5
%40 = zext i8 %39 to i32
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %38, i32 %40)
%42 = load i8, i8* %4
%43 = zext i8 %42 to i32
%44 = add nsw i32 %43, 1
%45 = trunc i32 %44 to i8
store i8 %45, i8* %4
br label %46
46: ; preds = %33
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %30
49: ; preds = %30
%50 = load i32, i32* @stdout
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %52
52: ; preds = %68, %49
%53 = load i32, i32* %3
%54 = icmp slt i32 %53, 256
br i1 %54, label %55, label %71
55: ; preds = %52
store i8 32, i8* %5
%56 = load i8, i8* %4
%57 = call zeroext i8 @daa(i8 zeroext %56, i8* %5)
store i8 %57, i8* %2
%58 = load i32, i32* @stdout
%59 = load i8, i8* %2
%60 = zext i8 %59 to i32
%61 = load i8, i8* %5
%62 = zext i8 %61 to i32
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %60, i32 %62)
%64 = load i8, i8* %4
%65 = zext i8 %64 to i32
%66 = add nsw i32 %65, 1
%67 = trunc i32 %66 to i8
store i8 %67, i8* %4
br label %68
68: ; preds = %55
%69 = load i32, i32* %3
%70 = add nsw i32 %69, 1
store i32 %70, i32* %3
br label %52
71: ; preds = %52
%72 = load i32, i32* @stdout
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %74
74: ; preds = %90, %71
%75 = load i32, i32* %3
%76 = icmp slt i32 %75, 256
br i1 %76, label %77, label %93
77: ; preds = %74
store i8 33, i8* %5
%78 = load i8, i8* %4
%79 = call zeroext i8 @daa(i8 zeroext %78, i8* %5)
store i8 %79, i8* %2
%80 = load i32, i32* @stdout
%81 = load i8, i8* %2
%82 = zext i8 %81 to i32
%83 = load i8, i8* %5
%84 = zext i8 %83 to i32
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %82, i32 %84)
%86 = load i8, i8* %4
%87 = zext i8 %86 to i32
%88 = add nsw i32 %87, 1
%89 = trunc i32 %88 to i8
store i8 %89, i8* %4
br label %90
90: ; preds = %77
%91 = load i32, i32* %3
%92 = add nsw i32 %91, 1
store i32 %92, i32* %3
br label %74
93: ; preds = %74
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [24 x i8] c"Carry: 0, Halfcarry: o\0A\00"
@.str.1 = [10 x i8] c"%02X%02X \00"
@.str.2 = [24 x i8] c"Carry: 1, Halfcarry: o\0A\00"
@.str.3 = [24 x i8] c"Carry: 0, Halfcarry: 1\0A\00"
@.str.4 = [24 x i8] c"Carry: 1, Halfcarry: 1\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = load i32, i32* @stdout
%3 = tail call i32 (i32, i8*, ...) @fprintf(i32 %2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %13, %4 ]
%6 = trunc i32 %5 to i8
store i8 0, i8* %1
%7 = call zeroext i8 @daa(i8 zeroext %6, i8* %1)
%8 = load i32, i32* @stdout
%9 = zext i8 %7 to i32
%10 = load i8, i8* %1
%11 = zext i8 %10 to i32
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %11)
%13 = add nuw nsw i32 %5, 1
%14 = icmp eq i32 %13, 256
br i1 %14, label %15, label %4
15: ; preds = %4
%16 = load i32, i32* @stdout
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %15, %18
%19 = phi i32 [ 0, %15 ], [ %27, %18 ]
%20 = trunc i32 %19 to i8
store i8 1, i8* %1
%21 = call zeroext i8 @daa(i8 zeroext %20, i8* %1)
%22 = load i32, i32* @stdout
%23 = zext i8 %21 to i32
%24 = load i8, i8* %1
%25 = zext i8 %24 to i32
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %25)
%27 = add nuw nsw i32 %19, 1
%28 = icmp eq i32 %27, 256
br i1 %28, label %29, label %18
29: ; preds = %18
%30 = load i32, i32* @stdout
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %29, %32
%33 = phi i32 [ 0, %29 ], [ %41, %32 ]
%34 = trunc i32 %33 to i8
store i8 32, i8* %1
%35 = call zeroext i8 @daa(i8 zeroext %34, i8* %1)
%36 = load i32, i32* @stdout
%37 = zext i8 %35 to i32
%38 = load i8, i8* %1
%39 = zext i8 %38 to i32
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %39)
%41 = add nuw nsw i32 %33, 1
%42 = icmp eq i32 %41, 256
br i1 %42, label %43, label %32
43: ; preds = %32
%44 = load i32, i32* @stdout
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %43, %46
%47 = phi i32 [ 0, %43 ], [ %55, %46 ]
%48 = trunc i32 %47 to i8
store i8 33, i8* %1
%49 = call zeroext i8 @daa(i8 zeroext %48, i8* %1)
%50 = load i32, i32* @stdout
%51 = zext i8 %49 to i32
%52 = load i8, i8* %1
%53 = zext i8 %52 to i32
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %51, i32 %53)
%55 = add nuw nsw i32 %47, 1
%56 = icmp eq i32 %55, 256
br i1 %56, label %57, label %46
57: ; preds = %46
ret i32 0
}