#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");
  printf("yes" ?: "no %d", 1);
}


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
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1169 <check_conditional_literal+0x59>
mov    -0xc(%rbp),%edx
lea    0xeb2(%rip),%rax
lea    0xea7(%rip),%rcx
cmp    $0x1,%edx
cmove  %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    1179 <check_conditional_literal+0x69>
lea    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1179 <check_conditional_literal+0x69>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11c2 <check_conditional_literal+0xb2>
cmpl   $0x1,-0xc(%rbp)
jne    11a5 <check_conditional_literal+0x95>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11b5 <check_conditional_literal+0xa5>
lea    0xe58(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11b5 <check_conditional_literal+0xa5>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11d2 <check_conditional_literal+0xc2>
lea    0xe3e(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11d2 <check_conditional_literal+0xc2>
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1c(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_conditional_literal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
cmp    $0x1,%esi
lea    0xed9(%rip),%r14
lea    0xed6(%rip),%rbp
mov    %rbp,%rdi
cmove  %r14,%rdi
cmovne %rbp,%rbx
xor    %eax,%eax
call   1030 <printf@plt>
test   %r15d,%r15d
lea    0xebd(%rip),%rax
cmovne %rax,%rbp
cmovne %rax,%rbx
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
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"
@.str.3 = [6 x i8] c"no %d\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 (i8*, ...) @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 (i8*, ...) @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 (i8*, ...) @printf(i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
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 (i8*, ...) @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 (i8*, ...) @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 (i8*, ...) @printf(i8* dereferenceable(1) %10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
ret void
}