#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 */
double atof(char *);
scalar_t__ strcmp(char *, char *);
double Scan_double(int argc, char **argv, char *flag, double value) {
  int i;
  for (i = 1; i < argc - 1; i++)
    if (strcmp(argv[i], flag) == 0)
      value = atof(argv[i + 1]);
  return (value);
}


x86 assembly (clang, -O0):
<Scan_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    119d <Scan_double+0x7d>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    118a <Scan_double+0x6a>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    118f <Scan_double+0x6f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113f <Scan_double+0x1f>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Scan_double>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
cmp    $0x3,%edi
jl     117f <Scan_double+0x5f>
mov    %rdx,%r14
mov    %rsi,%r12
mov    %edi,%r15d
add    $0xffffffff,%r15d
mov    $0x1,%ebx
jmp    1158 <Scan_double+0x38>
nopl   0x0(%rax)
mov    %r13,%rbx
cmp    %r13,%r15
je     117f <Scan_double+0x5f>
mov    (%r12,%rbx,8),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
lea    0x1(%rbx),%r13
test   %rax,%rax
jne    1150 <Scan_double+0x30>
mov    0x8(%r12,%rbx,8),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
jmp    1150 <Scan_double+0x30>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @Scan_double(i32 %0, i8** %1, i8* %2, double %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca double
%9 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store double %3, double* %8
store i32 1, i32* %9
br label %10
10: ; preds = %33, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %5
%13 = sub nsw i32 %12, 1
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %36
15: ; preds = %10
%16 = load i8**, i8*** %6
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = load i8*, i8** %7
%22 = call i64 @strcmp(i8* %20, i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %15
%25 = load i8**, i8*** %6
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %25, i64 %28
%30 = load i8*, i8** %29
%31 = call double @atof(i8* %30)
store double %31, double* %8
br label %32
32: ; preds = %24, %15
br label %33
33: ; preds = %32
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %10
36: ; preds = %10
%37 = load double, double* %8
ret double %37
}

LLVM IR (-O2):
define double @Scan_double(i32 %0, i8** nocapture %1, i8* %2, double %3) {
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %24
6: ; preds = %4
%7 = add nsw i32 %0, -1
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %6, %21
%10 = phi i64 [ 1, %6 ], [ %16, %21 ]
%11 = phi double [ %3, %6 ], [ %22, %21 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %10
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* %2)
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %10, 1
br i1 %15, label %17, label %21
17: ; preds = %9
%18 = getelementptr inbounds i8*, i8** %1, i64 %16
%19 = load i8*, i8** %18
%20 = tail call double @atof(i8* %19)
br label %21
21: ; preds = %9, %17
%22 = phi double [ %20, %17 ], [ %11, %9 ]
%23 = icmp eq i64 %16, %8
br i1 %23, label %24, label %9
24: ; preds = %21, %4
%25 = phi double [ %3, %4 ], [ %22, %21 ]
ret double %25
}