#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*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ stderr;
double strtod(char *, char **);
int read_number_switch(const char *arg, int argc, char **argv, double *out) {
  int ok = 1;
  if (argc == 0) {
    fprintf(stderr, "Error: Expected value following %s\n", arg);
    ok = 0;
  } else {
    char *endptr = 0;
    *out = strtod(argv[0], &endptr);
    if (endptr == 0 || *endptr != 0) {
      fprintf(stderr, "Error: Invalid value %s following %s\n", argv[0], arg);
      ok = 0;
    }
  }
  return ok;
}


x86 assembly (clang, -O0):
<read_number_switch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    116f <read_number_switch+0x4f>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
jmp    11d8 <read_number_switch+0xb8>
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <strtod@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,-0x30(%rbp)
je     11aa <read_number_switch+0x8a>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d3 <read_number_switch+0xb3>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
jmp    11d8 <read_number_switch+0xb8>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_number_switch>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
test   %esi,%esi
je     1180 <read_number_switch+0x60>
mov    %rcx,%rbx
mov    %rdx,%rbp
movq   $0x0,0x8(%rsp)
mov    (%rdx),%rdi
lea    0x8(%rsp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,(%rbx)
mov    0x8(%rsp),%rax
test   %rax,%rax
je     115e <read_number_switch+0x3e>
cmpb   $0x0,(%rax)
je     119e <read_number_switch+0x7e>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xeb2(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11a3 <read_number_switch+0x83>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11a3 <read_number_switch+0x83>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Error: Expected value following %s\0A\00"
@.str.1 = [38 x i8] c"Error: Invalid value %s following %s\0A\00"
define i32 @read_number_switch(i8* %0, i32 %1, i8** %2, double* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca double*
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store double* %3, double** %8
store i32 1, i32* %9
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %5
%16 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 0, i32* %9
br label %38
17: ; preds = %4
store i8* null, i8** %10
%18 = load i8**, i8*** %7
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call double @strtod(i8* %20, i8** %10)
%22 = load double*, double** %8
store double %21, double* %22
%23 = load i8*, i8** %10
%24 = icmp eq i8* %23, null
br i1 %24, label %30, label %25
25: ; preds = %17
%26 = load i8*, i8** %10
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %25, %17
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %7
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = load i8*, i8** %5
%36 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %34, i8* %35)
store i32 0, i32* %9
br label %37
37: ; preds = %30, %25
br label %38
38: ; preds = %37, %13
%39 = load i32, i32* %9
ret i32 %39
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Error: Expected value following %s\0A\00"
@.str.1 = [38 x i8] c"Error: Invalid value %s following %s\0A\00"
define i32 @read_number_switch(i8* %0, i32 %1, i8** nocapture %2, double* nocapture writeonly %3) {
%5 = alloca i8*
%6 = icmp eq i32 %1, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %25
10: ; preds = %4
%11 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%12 = load i8*, i8** %2
%13 = call double @strtod(i8* %12, i8** %5)
store double %13, double* %3
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, null
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = load i8, i8* %14
%18 = icmp eq i8 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %16, %10
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %2
%22 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %0)
br label %23
23: ; preds = %19, %16
%24 = phi i32 [ 0, %19 ], [ 1, %16 ]
br label %25
25: ; preds = %23, %7
%26 = phi i32 [ 0, %7 ], [ %24, %23 ]
ret i32 %26
}