#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 *, char *, int, int);
void draw_then_const(FILE *fp, int x, int y, int c) {
  fprintf(fp, "(%s) %d %d then_const\n", c == 2 ? "X" : c ? "1" : "0", x, y);
}


x86 assembly (clang, -O0):
<draw_then_const>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x14(%rbp)
jne    1147 <draw_then_const+0x37>
lea    0xed9(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1163 <draw_then_const+0x53>
mov    -0x14(%rbp),%edx
lea    0xeca(%rip),%rax
lea    0xec1(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe87(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_then_const>:
mov    %edx,%r8d
mov    %esi,%eax
test   %ecx,%ecx
lea    0xefd(%rip),%rdx
lea    0xef4(%rip),%rsi
cmove  %rdx,%rsi
cmp    $0x2,%ecx
lea    0xee4(%rip),%rdx
cmovne %rsi,%rdx
lea    0xec2(%rip),%rsi
mov    %eax,%ecx
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"(%s) %d %d then_const\0A\00"
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
define void @draw_then_const(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32*, i32** %5
%10 = load i32, i32* %8
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %4
br label %18
13: ; preds = %4
%14 = load i32, i32* %8
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
br label %18
18: ; preds = %13, %12
%19 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %12 ], [ %17, %13 ]
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %20, i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"(%s) %d %d then_const\0A\00"
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
define void @draw_then_const(i32* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 2
%6 = icmp eq i32 %3, 0
%7 = select i1 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%8 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %7
%9 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %1, i32 %2)
ret void
}