#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*/ cgpop2();
int /*<<< orphan*/ gen(char *);
int /*<<< orphan*/ genlab(int);
int label();
int /*<<< orphan*/ lgen(char *, char *, int);
void cgcmp(char *inst) {
  int lab = label();
  gen("xorl\t%edx,%edx");
  cgpop2();
  gen("cmpl\t%eax,%ecx");
  lgen("%s\t%c%d", inst, lab);
  gen("incl\t%edx");
  genlab(lab);
  gen("movl\t%edx,%eax");
}


x86 assembly (clang, -O0):
<cgcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <label@plt>
mov    %eax,-0xc(%rbp)
lea    0xe93(%rip),%rdi
call   1070 <gen@plt>
mov    $0x0,%al
call   1050 <cgpop2@plt>
lea    0xe8f(%rip),%rdi
call   1070 <gen@plt>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xe8b(%rip),%rdi
call   1030 <lgen@plt>
lea    0xe87(%rip),%rdi
call   1070 <gen@plt>
mov    -0xc(%rbp),%edi
call   1060 <genlab@plt>
lea    0xe7d(%rip),%rdi
call   1070 <gen@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgcmp>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <label@plt>
mov    %eax,%ebp
lea    0xe9a(%rip),%rdi
call   1070 <gen@plt>
xor    %eax,%eax
call   1050 <cgpop2@plt>
lea    0xe96(%rip),%rdi
call   1070 <gen@plt>
lea    0xe99(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <lgen@plt>
lea    0xe90(%rip),%rdi
call   1070 <gen@plt>
mov    %ebp,%edi
call   1060 <genlab@plt>
lea    0xe87(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <gen@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"xorl\09%edx,%edx\00"
@.str.1 = [15 x i8] c"cmpl\09%eax,%ecx\00"
@.str.2 = [8 x i8] c"%s\09%c%d\00"
@.str.3 = [10 x i8] c"incl\09%edx\00"
@.str.4 = [15 x i8] c"movl\09%edx,%eax\00"
define void @cgcmp(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 (...) @label()
store i32 %4, i32* %3
%5 = call i32 @gen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @cgpop2()
%7 = call i32 @gen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = call i32 @lgen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %8, i32 %9)
%11 = call i32 @gen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* %3
%13 = call i32 @genlab(i32 %12)
%14 = call i32 @gen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"xorl\09%edx,%edx\00"
@.str.1 = [15 x i8] c"cmpl\09%eax,%ecx\00"
@.str.2 = [8 x i8] c"%s\09%c%d\00"
@.str.3 = [10 x i8] c"incl\09%edx\00"
@.str.4 = [15 x i8] c"movl\09%edx,%eax\00"
define void @cgcmp(i8* %0) {
%2 = tail call i32 (...) @label()
%3 = tail call i32 @gen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @cgpop2()
%5 = tail call i32 @gen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @lgen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %2)
%7 = tail call i32 @gen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @genlab(i32 %2)
%9 = tail call i32 @gen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
ret void
}