#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*/ resp;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int rpmatch(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
int queryuser(char *argv[]) {
  char *p, resp[256];
  (void)fprintf(stderr, "\"%s", *argv);
  while (*++argv)
    (void)fprintf(stderr, " %s", *argv);
  (void)fprintf(stderr, "\"? ");
  (void)fflush(stderr);
  if (fgets(resp, sizeof(resp), stdin) == NULL)
    *resp = '\0';
  if ((p = strchr(resp, '\n')) != NULL)
    *p = '\0';
  else {
    (void)fprintf(stderr, "\n");
    (void)fflush(stderr);
  }
  return (rpmatch(resp) == 1);
}


x86 assembly (clang, -O0):
<queryuser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
cmpq   $0x0,0x8(%rax)
je     11ba <queryuser+0x6a>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    117d <queryuser+0x2d>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x110(%rbp),%rdi
mov    0x2dfb(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    120a <queryuser+0xba>
movb   $0x0,-0x110(%rbp)
lea    -0x110(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1235 <queryuser+0xe5>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    125a <queryuser+0x10a>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x110(%rbp),%rdi
call   1060 <rpmatch@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<queryuser>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rbx
mov    0x2e72(%rip),%r15
mov    (%r15),%edi
mov    (%rbx),%rdx
lea    0xe8d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x8(%rbx),%rdx
test   %rdx,%rdx
je     11a9 <queryuser+0x59>
add    $0x10,%rbx
lea    0xe76(%rip),%r14
xchg   %ax,%ax
mov    (%r15),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%rdx
add    $0x8,%rbx
test   %rdx,%rdx
jne    1190 <queryuser+0x40>
mov    (%r15),%edi
lea    0xe55(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%edi
call   1070 <fflush@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1040 <fgets@plt>
test   %rax,%rax
jne    11e1 <queryuser+0x91>
movb   $0x0,(%rsp)
mov    %rsp,%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11f8 <queryuser+0xa8>
movb   $0x0,(%rax)
jmp    1211 <queryuser+0xc1>
mov    (%r15),%edi
lea    0xe0a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%edi
call   1070 <fflush@plt>
mov    %rsp,%rdi
call   1060 <rpmatch@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
mov    %ecx,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [4 x i8] c"\22%s\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [4 x i8] c"\22? \00"
@stdin = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
define i32 @queryuser(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca [256 x i8]
store i8** %0, i8*** %2
%5 = load i32, i32* @stderr
%6 = load i8**, i8*** %2
%7 = load i8*, i8** %6
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %14, %1
%10 = load i8**, i8*** %2
%11 = getelementptr inbounds i8*, i8** %10, i32 1
store i8** %11, i8*** %2
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %2
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %9
19: ; preds = %9
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* @stderr
%23 = call i32 @fflush(i32 %22)
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%25 = load i32, i32* @stdin
%26 = call i32* @fgets(i8* %24, i32 256, i32 %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %19
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
store i8 0, i8* %29
br label %30
30: ; preds = %28, %19
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%32 = call i8* @strchr(i8* %31, i8 signext 10)
store i8* %32, i8** %3
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i8*, i8** %3
store i8 0, i8* %35
br label %41
36: ; preds = %30
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32, i32* @stderr
%40 = call i32 @fflush(i32 %39)
br label %41
41: ; preds = %36, %34
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%43 = call i32 @rpmatch(i8* %42)
%44 = icmp eq i32 %43, 1
%45 = zext i1 %44 to i32
ret i32 %45
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"\22%s\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [4 x i8] c"\22? \00"
@stdin = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
define i32 @queryuser(i8** nocapture %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stderr
%5 = load i8*, i8** %0
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds i8*, i8** %0, i64 1
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %18, label %10
10: ; preds = %1, %10
%11 = phi i8* [ %16, %10 ], [ %8, %1 ]
%12 = phi i8** [ %15, %10 ], [ %7, %1 ]
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%15 = getelementptr inbounds i8*, i8** %12, i64 1
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %10
18: ; preds = %10, %1
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 @fflush(i32 %21)
%23 = load i32, i32* @stdin
%24 = call i32* @fgets(i8* %3, i32 256, i32 %23)
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %27
26: ; preds = %18
store i8 0, i8* %3
br label %27
27: ; preds = %26, %18
%28 = call i8* @strchr(i8* %3, i8 signext 10)
%29 = icmp eq i8* %28, null
br i1 %29, label %31, label %30
30: ; preds = %27
store i8 0, i8* %28
br label %36
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = call i32 @fflush(i32 %34)
br label %36
36: ; preds = %31, %30
%37 = call i32 @rpmatch(i8* %3)
%38 = icmp eq i32 %37, 1
%39 = zext i1 %38 to i32
ret i32 %39
}