#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 */
int /*<<< orphan*/ cprintf(char *, int);
int format_log();
int /*<<< orphan*/ textattr(int);
int format_fdd() {
  int status;
  status = format_log();
  if (status == 2) {
    textattr(0x0C);
    cprintf("\n\rFormat incomplete. Data error. STATUS: %d", status);
    textattr(0x07);
  } else if (status == 1) {
    textattr(0x0C);
    cprintf("\n\rFormat incomplete. Failed. STATUS: %d", status);
    textattr(0x07);
  } else {
    textattr(0x03);
    cprintf("\n\rFormat complete. STATUS: %d", status);
    textattr(0x07);
  }
  return status;
}


x86 assembly (clang, -O0):
<format_fdd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <format_log@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    1174 <format_fdd+0x44>
mov    $0xc,%edi
call   1030 <textattr@plt>
mov    -0x4(%rbp),%esi
lea    0xea0(%rip),%rdi
call   1040 <cprintf@plt>
mov    $0x7,%edi
call   1030 <textattr@plt>
jmp    11ce <format_fdd+0x9e>
cmpl   $0x1,-0x4(%rbp)
jne    11a6 <format_fdd+0x76>
mov    $0xc,%edi
call   1030 <textattr@plt>
mov    -0x4(%rbp),%esi
lea    0xe9a(%rip),%rdi
call   1040 <cprintf@plt>
mov    $0x7,%edi
call   1030 <textattr@plt>
jmp    11c9 <format_fdd+0x99>
mov    $0x3,%edi
call   1030 <textattr@plt>
mov    -0x4(%rbp),%esi
lea    0xe9a(%rip),%rdi
call   1040 <cprintf@plt>
mov    $0x7,%edi
call   1030 <textattr@plt>
jmp    11ce <format_fdd+0x9e>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_fdd>:
push   %rbx
xor    %eax,%eax
call   1050 <format_log@plt>
mov    %eax,%ebx
cmp    $0x1,%eax
je     115c <format_fdd+0x2c>
cmp    $0x2,%ebx
jne    1174 <format_fdd+0x44>
mov    $0xc,%edi
call   1030 <textattr@plt>
lea    0xeab(%rip),%rdi
mov    $0x2,%esi
jmp    1187 <format_fdd+0x57>
mov    $0xc,%edi
call   1030 <textattr@plt>
lea    0xebf(%rip),%rdi
mov    $0x1,%esi
jmp    1187 <format_fdd+0x57>
mov    $0x3,%edi
call   1030 <textattr@plt>
lea    0xecf(%rip),%rdi
mov    %ebx,%esi
call   1040 <cprintf@plt>
mov    $0x7,%edi
call   1030 <textattr@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [44 x i8] c"\0A\0DFormat incomplete. Data error. STATUS: %d\00"
@.str.1 = [40 x i8] c"\0A\0DFormat incomplete. Failed. STATUS: %d\00"
@.str.2 = [30 x i8] c"\0A\0DFormat complete. STATUS: %d\00"
define i32 @format_fdd() {
%1 = alloca i32
%2 = call i32 (...) @format_log()
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp eq i32 %3, 2
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = call i32 @textattr(i32 12)
%7 = load i32, i32* %1
%8 = call i32 @cprintf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @textattr(i32 7)
br label %24
10: ; preds = %0
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = call i32 @textattr(i32 12)
%15 = load i32, i32* %1
%16 = call i32 @cprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 @textattr(i32 7)
br label %23
18: ; preds = %10
%19 = call i32 @textattr(i32 3)
%20 = load i32, i32* %1
%21 = call i32 @cprintf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = call i32 @textattr(i32 7)
br label %23
23: ; preds = %18, %13
br label %24
24: ; preds = %23, %5
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [44 x i8] c"\0A\0DFormat incomplete. Data error. STATUS: %d\00"
@.str.1 = [40 x i8] c"\0A\0DFormat incomplete. Failed. STATUS: %d\00"
@.str.2 = [30 x i8] c"\0A\0DFormat complete. STATUS: %d\00"
define i32 @format_fdd() {
%1 = tail call i32 (...) @format_log()
switch i32 %1, label %8 [
i32 2, label %2
i32 1, label %5
]
2: ; preds = %0
%3 = tail call i32 @textattr(i32 12)
%4 = tail call i32 @cprintf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 2)
br label %11
5: ; preds = %0
%6 = tail call i32 @textattr(i32 12)
%7 = tail call i32 @cprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %11
8: ; preds = %0
%9 = tail call i32 @textattr(i32 3)
%10 = tail call i32 @cprintf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %1)
br label %11
11: ; preds = %5, %8, %2
%12 = tail call i32 @textattr(i32 7)
ret i32 %1
}