#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 matoi(char *);
int /*<<< orphan*/ printf(char *, char const *);
scalar_t__ readline(char *, char *, char *, int);
int selstr(const char *s1, const char *s2) {
  char ans[3];
  printf("1: %s\n", s1);
  printf("2: %s\n", s2);
  if (readline("Keep (1/2)", ans, "1", 3))
    return 1;
  else
    return matoi(ans);
}


x86 assembly (clang, -O0):
<selstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1b(%rbp),%rsi
lea    0xea3(%rip),%rdi
lea    0xea7(%rip),%rdx
mov    $0x3,%ecx
call   1040 <readline@plt>
cmp    $0x0,%rax
je     1192 <selstr+0x62>
movl   $0x1,-0x4(%rbp)
jmp    119e <selstr+0x6e>
lea    -0x1b(%rbp),%rdi
call   1050 <matoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selstr>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    0xeb5(%rip),%rdx
lea    0xd(%rsp),%rsi
mov    $0x3,%ecx
call   1040 <readline@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    118a <selstr+0x5a>
lea    0xd(%rsp),%rdi
call   1050 <matoi@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"1: %s\0A\00"
@.str.1 = [7 x i8] c"2: %s\0A\00"
@.str.2 = [11 x i8] c"Keep (1/2)\00"
@.str.3 = [2 x i8] c"1\00"
define i32 @selstr(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [3 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i8*, i8** %5
%10 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%12 = call i64 @readline(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 3)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %3
br label %18
15: ; preds = %2
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%17 = call i32 @matoi(i8* %16)
store i32 %17, i32* %3
br label %18
18: ; preds = %15, %14
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@.str = [7 x i8] c"1: %s\0A\00"
@.str.1 = [7 x i8] c"2: %s\0A\00"
@.str.2 = [11 x i8] c"Keep (1/2)\00"
@.str.3 = [2 x i8] c"1\00"
define i32 @selstr(i8* %0, i8* %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%7 = call i64 @readline(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @matoi(i8* %4)
br label %11
11: ; preds = %2, %9
%12 = phi i32 [ %10, %9 ], [ 1, %2 ]
ret i32 %12
}