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


x86 assembly (clang, -O0):
<write_reclass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114a <write_reclass+0x3a>
movq   $0x0,-0x18(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1199 <write_reclass+0x89>
cmpl   $0x0,-0x24(%rbp)
je     1199 <write_reclass+0x89>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11af <write_reclass+0x9f>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_reclass>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%ebp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
test   %rsi,%rsi
lea    0xed2(%rip),%r12
cmovne %rcx,%r12
lea    0xecf(%rip),%rsi
mov    %rbx,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %ebp,%ebp
je     1160 <write_reclass+0x50>
cmpb   $0x0,(%r12)
je     1160 <write_reclass+0x50>
lea    0xebb(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
jmp    1174 <write_reclass+0x64>
test   %rbx,%rbx
cmove  %rbx,%r14
lea    0xea9(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
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 = [5 x i8] c"%ld\0A\00"
define i32 @write_reclass(i32* %0, i64 %1, i64 %2, i8* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32
store i32* %0, i32** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%11 = load i64, i64* %7
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %5
store i64 0, i64* %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %9
br label %14
14: ; preds = %13, %5
%15 = load i32*, i32** %6
%16 = load i64, i64* %7
%17 = load i64, i64* %7
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %16, i64 %17)
%19 = load i8*, i8** %9
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %14
%24 = load i32, i32* %10
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32*, i32** %6
%28 = load i8*, i8** %9
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %34
30: ; preds = %23, %14
%31 = load i32*, i32** %6
%32 = load i64, i64* %8
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %32)
br label %34
34: ; preds = %30, %26
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 = [5 x i8] c"%ld\0A\00"
define i32 @write_reclass(i32* nocapture %0, i64 %1, i64 %2, i8* %3, i32 %4) {
%6 = icmp eq i64 %1, 0
%7 = select i1 %6, 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 %1)
%9 = load i8, i8* %7
%10 = icmp ne i8 %9, 0
%11 = icmp ne i32 %4, 0
%12 = and i1 %11, %10
br i1 %12, label %13, label %15
13: ; preds = %5
%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 %18
15: ; preds = %5
%16 = select i1 %6, i64 0, i64 %2
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %16)
br label %18
18: ; preds = %15, %13
ret i32 0
}