#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*/ printf(char const *);
void check_conditional_literal(const char *s, int i) {
  printf(i == 1 ? "yes" : "no");
  printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know");
  printf(i == 0 ? (i == 1 ? s : "no") : "dont know");
}


x86 assembly (clang, -O0):
<check_conditional_literal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
lea    0xedb(%rip),%rdi
lea    0xed0(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1167 <check_conditional_literal+0x57>
mov    -0xc(%rbp),%edx
lea    0xeb4(%rip),%rax
lea    0xea9(%rip),%rcx
cmp    $0x1,%edx
cmove  %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    1177 <check_conditional_literal+0x67>
lea    0xe99(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1177 <check_conditional_literal+0x67>
mov    -0x18(%rbp),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11be <check_conditional_literal+0xae>
cmpl   $0x1,-0xc(%rbp)
jne    11a1 <check_conditional_literal+0x91>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11b1 <check_conditional_literal+0xa1>
lea    0xe5c(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11b1 <check_conditional_literal+0xa1>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11ce <check_conditional_literal+0xbe>
lea    0xe42(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11ce <check_conditional_literal+0xbe>
mov    -0x28(%rbp),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_conditional_literal>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
cmp    $0x1,%esi
lea    0xedc(%rip),%rdi
lea    0xed9(%rip),%rbp
cmovne %rbp,%rdi
cmovne %rbp,%rbx
call   1030 <printf@plt>
test   %r14d,%r14d
lea    0xec5(%rip),%rax
cmovne %rax,%rbp
cmovne %rax,%rbx
mov    %rbp,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"yes\00"
@.str.1 = [3 x i8] c"no\00"
@.str.2 = [10 x i8] c"dont know\00"
define void @check_conditional_literal(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 1
%7 = zext i1 %6 to i64
%8 = select i1 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%9 = call i32 @printf(i8* %8)
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 1
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
br label %18
17: ; preds = %2
br label %18
18: ; preds = %17, %12
%19 = phi i8* [ %16, %12 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %17 ]
%20 = call i32 @printf(i8* %19)
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %18
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i8*, i8** %3
br label %29
28: ; preds = %23
br label %29
29: ; preds = %28, %26
%30 = phi i8* [ %27, %26 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %28 ]
br label %32
31: ; preds = %18
br label %32
32: ; preds = %31, %29
%33 = phi i8* [ %30, %29 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %31 ]
%34 = call i32 @printf(i8* %33)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"yes\00"
@.str.1 = [3 x i8] c"no\00"
@.str.2 = [10 x i8] c"dont know\00"
define void @check_conditional_literal(i8* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 1
%4 = select i1 %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%5 = tail call i32 @printf(i8* dereferenceable(1) %4)
%6 = icmp eq i32 %1, 0
%7 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0)
%8 = tail call i32 @printf(i8* dereferenceable(1) %7)
%9 = select i1 %3, i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%10 = select i1 %6, i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0)
%11 = tail call i32 @printf(i8* dereferenceable(1) %10)
ret void
}