#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int write_reclass(FILE *fd, long cat1, long cat2, char *label) {
  if (cat1 == 0) {
    cat2 = 0;
    label = "no data";
  }
  fprintf(fd, "%ld = %ld ", cat1, cat2);
  if (label && *label)
    fprintf(fd, "%s\n", label);
  else
    fprintf(fd, "(Category %ld)\n", cat2);
  return 0;
}


x86 assembly (clang, -O0):
<write_reclass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1146 <write_reclass+0x36>
movq   $0x0,-0x18(%rbp)
lea    0xebe(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1196 <write_reclass+0x86>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1196 <write_reclass+0x86>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11ac <write_reclass+0x9c>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_reclass>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rdx
test   %rsi,%rsi
cmove  %rsi,%r15
mov    %rdi,%r14
lea    0xed4(%rip),%rbx
cmovne %rcx,%rbx
lea    0xed1(%rip),%rsi
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %rbx,%rbx
je     115a <write_reclass+0x4a>
cmpb   $0x0,(%rbx)
je     115a <write_reclass+0x4a>
lea    0xec1(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
jmp    1167 <write_reclass+0x57>
lea    0xeb6(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"no data\00"
@.str.1 = [11 x i8] c"%ld = %ld \00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [16 x i8] c"(Category %ld)\0A\00"
define i32 @write_reclass(i32* %0, i64 %1, i64 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store i32* %0, i32** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%9 = load i64, i64* %6
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %4
store i64 0, i64* %7
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %8
br label %12
12: ; preds = %11, %4
%13 = load i32*, i32** %5
%14 = load i64, i64* %6
%15 = load i64, i64* %7
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %14, i64 %15)
%17 = load i8*, i8** %8
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %28
19: ; preds = %12
%20 = load i8*, i8** %8
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load i32*, i32** %5
%26 = load i8*, i8** %8
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %32
28: ; preds = %19, %12
%29 = load i32*, i32** %5
%30 = load i64, i64* %7
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i64 %30)
br label %32
32: ; preds = %28, %24
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"no data\00"
@.str.1 = [11 x i8] c"%ld = %ld \00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [16 x i8] c"(Category %ld)\0A\00"
define i32 @write_reclass(i32* nocapture %0, i64 %1, i64 %2, i8* %3) {
%5 = icmp eq i64 %1, 0
%6 = select i1 %5, i64 0, i64 %2
%7 = select i1 %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %3
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %1, i64 %6)
%9 = icmp eq i8* %7, null
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = load i8, i8* %7
%12 = icmp eq i8 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %17
15: ; preds = %10, %4
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i64 %6)
br label %17
17: ; preds = %15, %13
ret i32 0
}