#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 EXIT_SUCCESS;
int /*<<< orphan*/ assert(int);
char *basename(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int scanf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(int argc, char **argv) {
  (void)argc;
  char *progname = basename(argv[0]);
  char err_buffer[256];
  char err_buf_fmt[16];
  sprintf(err_buf_fmt, "%%%lds", sizeof err_buffer - 1);
  printf("err_buf_fmt = \"%s\"\n", err_buf_fmt);
  for (;;) {
    double number;
    int scancount = scanf("%lg", &number);
    if (scancount == EOF) {
      printf("%s: EOF\n", progname);
      break;
    } else if (scancount == 1) {
      printf("%s: number = %.15g\n", progname, number);
    } else {
      scancount = scanf(err_buf_fmt, err_buffer);
      assert(scancount == 1);
      printf("%s: bad number \"%s\"\n", progname, err_buffer);
    };
  };
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <basename@plt>
mov    %rax,-0x18(%rbp)
lea    -0x130(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0xff,%edx
call   1070 <sprintf@plt>
lea    -0x130(%rbp),%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6e(%rip),%rdi
lea    -0x138(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x13c(%rbp)
mov    -0x13c(%rbp),%eax
mov    0x2e1a(%rip),%rcx
cmp    (%rcx),%eax
jne    11ed <main+0x9d>
mov    -0x18(%rbp),%rsi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126b <main+0x11b>
cmpl   $0x1,-0x13c(%rbp)
jne    1219 <main+0xc9>
mov    -0x18(%rbp),%rsi
movsd  -0x138(%rbp),%xmm0
ff
lea    0xe1b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1261 <main+0x111>
lea    -0x130(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x13c(%rbp)
cmpl   $0x1,-0x13c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rsi
lea    -0x120(%rbp),%rdx
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <main+0x116>
jmp    11a6 <main+0x56>
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    (%rsi),%rdi
call   1050 <basename@plt>
mov    %rax,%rbx
lea    0xe8d(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xff,%edx
call   1070 <sprintf@plt>
lea    0xe7b(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x2e38(%rip),%r13
cmp    0x0(%r13),%eax
jne    11e2 <main+0x92>
lea    0xe62(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe32(%rip),%r15
lea    0x8(%rsp),%r12
lea    0x20(%rsp),%rbp
lea    0xe42(%rip),%r14
jmp    1244 <main+0xf4>
nopl   0x0(%rax)
lea    0x10(%rsp),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1040 <assert@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    0x0(%r13),%eax
je     11b6 <main+0x66>
cmp    $0x1,%eax
jne    1200 <main+0xb0>
movsd  0x8(%rsp),%xmm0
lea    0xdd2(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    122d <main+0xdd>

LLVM IR (-O0):
@.str = [7 x i8] c"%%%lds\00"
@.str.1 = [20 x i8] c"err_buf_fmt = \22%s\22\0A\00"
@.str.2 = [4 x i8] c"%lg\00"
@EOF = global i32 0
@.str.3 = [9 x i8] c"%s: EOF\0A\00"
@.str.4 = [20 x i8] c"%s: number = %.15g\0A\00"
@.str.5 = [21 x i8] c"%s: bad number \22%s\22\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [256 x i8]
%8 = alloca [16 x i8]
%9 = alloca double
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i8* @basename(i8* %14)
store i8* %15, i8** %6
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%17 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 255)
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %47, %2
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %9)
store i32 %21, i32* %10
%22 = load i32, i32* %10
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i8*, i8** %6
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %26)
br label %48
28: ; preds = %20
%29 = load i32, i32* %10
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i8*, i8** %6
%33 = load double, double* %9
%34 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %32, double %33)
br label %46
35: ; preds = %28
%36 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%38 = call i32 (i8*, ...) @scanf(i8* %36, i8* %37)
store i32 %38, i32* %10
%39 = load i32, i32* %10
%40 = icmp eq i32 %39, 1
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load i8*, i8** %6
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%45 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %43, i8* %44)
br label %46
46: ; preds = %35, %31
br label %47
47: ; preds = %46
br label %20
48: ; preds = %25
%49 = load i32, i32* @EXIT_SUCCESS
ret i32 %49
}

LLVM IR (-O2):
@.str = [7 x i8] c"%%%lds\00"
@.str.1 = [20 x i8] c"err_buf_fmt = \22%s\22\0A\00"
@.str.2 = [4 x i8] c"%lg\00"
@EOF = global i32 0
@.str.3 = [9 x i8] c"%s: EOF\0A\00"
@.str.4 = [20 x i8] c"%s: number = %.15g\0A\00"
@.str.5 = [21 x i8] c"%s: bad number \22%s\22\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [16 x i8]
%5 = alloca double
%6 = load i8*, i8** %1
%7 = tail call i8* @basename(i8* %6)
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%10 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 255)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%12 = bitcast double* %5 to i8*
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %32, label %16
16: ; preds = %2, %28
%17 = phi i32 [ %29, %28 ], [ %13, %2 ]
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load double, double* %5
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %7, double %20)
br label %28
22: ; preds = %16
%23 = call i32 (i8*, ...) @scanf(i8* %9, i8* %8)
%24 = icmp eq i32 %23, 1
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %7, i8* %8)
br label %28
28: ; preds = %22, %19
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %16
32: ; preds = %28, %2
%33 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%34 = load i32, i32* @EXIT_SUCCESS
ret i32 %34
}