#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 EOF;
int scanf(char *, ...);
int getop(double *dptr, char *cptr) {
  int doubleres = 0;
  int charres = 0;
  doubleres = scanf("%lf", dptr);
  if (doubleres == 1)
    return '0';
  charres = scanf(" %c", cptr);
  if (charres == 1)
    return 1;
  return EOF;
}


x86 assembly (clang, -O0):
<getop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1159 <getop+0x49>
movl   $0x30,-0x4(%rbp)
jmp    1190 <getop+0x80>
mov    -0x18(%rbp),%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    1184 <getop+0x74>
movl   $0x1,-0x4(%rbp)
jmp    1190 <getop+0x80>
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getop>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xee2(%rip),%rdi
xor    %eax,%eax
call   1030 <scanf@plt>
mov    %eax,%ecx
mov    $0x30,%eax
cmp    $0x1,%ecx
je     1150 <getop+0x40>
lea    0xecc(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     1150 <getop+0x40>
mov    0x2e9a(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [4 x i8] c" %c\00"
@EOF = global i32 0
define i32 @getop(double* %0, i8* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store i8* %1, i8** %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load double*, double** %4
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 48, i32* %3
br label %21
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 1, i32* %3
br label %21
19: ; preds = %13
%20 = load i32, i32* @EOF
store i32 %20, i32* %3
br label %21
21: ; preds = %19, %18, %12
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [4 x i8] c" %c\00"
@EOF = global i32 0
define i32 @getop(double* %0, i8* %1) {
%3 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %0)
%4 = icmp eq i32 %3, 1
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%7 = icmp eq i32 %6, 1
%8 = load i32, i32* @EOF
%9 = select i1 %7, i32 1, i32 %8
br label %10
10: ; preds = %5, %2
%11 = phi i32 [ 48, %2 ], [ %9, %5 ]
ret i32 %11
}