#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 *);
char *ext_arg(char *, char *);
scalar_t__ strcmp(char *, char *);
double cal_max(char *S) {
  char *tmp = S;
  char arg[50];
  tmp = ext_arg(tmp, arg);
  double max = atof(arg);
  for (; strcmp(tmp, "") != 0;) {
    tmp = ext_arg(tmp, arg);
    max = atof(arg) > max ? atof(arg) : max;
  }
  return max;
}


x86 assembly (clang, -O0):
<cal_max>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <ext_arg@plt>
mov    %rax,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11ce <cal_max+0x9e>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <ext_arg@plt>
mov    %rax,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <atof@plt>
ucomisd -0x58(%rbp),%xmm0
jbe    11b5 <cal_max+0x85>
lea    -0x50(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x60(%rbp)
jmp    11bf <cal_max+0x8f>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1163 <cal_max+0x33>
movsd  -0x58(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal_max>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0x10(%rsp),%r14
mov    %r14,%rsi
call   1040 <ext_arg@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <atof@plt>
movsd  %xmm0,(%rsp)
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11be <cal_max+0x8e>
lea    0x10(%rsp),%r14
lea    0xe8a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <ext_arg@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <atof@plt>
maxsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
test   %rax,%rax
jne    1180 <cal_max+0x50>
jmp    11c3 <cal_max+0x93>
movsd  (%rsp),%xmm0
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define double @cal_max(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [50 x i8]
%5 = alloca double
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%9 = call i8* @ext_arg(i8* %7, i8* %8)
store i8* %9, i8** %3
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%11 = call double @atof(i8* %10)
store double %11, double* %5
br label %12
12: ; preds = %29, %1
%13 = load i8*, i8** %3
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %31
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%19 = call i8* @ext_arg(i8* %17, i8* %18)
store i8* %19, i8** %3
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%21 = call double @atof(i8* %20)
%22 = load double, double* %5
%23 = fcmp ogt double %21, %22
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%26 = call double @atof(i8* %25)
br label %29
27: ; preds = %16
%28 = load double, double* %5
br label %29
29: ; preds = %27, %24
%30 = phi double [ %26, %24 ], [ %28, %27 ]
store double %30, double* %5
br label %12
31: ; preds = %12
%32 = load double, double* %5
ret double %32
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define double @cal_max(i8* %0) {
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%4 = call i8* @ext_arg(i8* %0, i8* %3)
%5 = call double @atof(i8* %3)
%6 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %1, %8
%9 = phi double [ %14, %8 ], [ %5, %1 ]
%10 = phi i8* [ %11, %8 ], [ %4, %1 ]
%11 = call i8* @ext_arg(i8* %10, i8* %3)
%12 = call double @atof(i8* %3)
%13 = fcmp ogt double %12, %9
%14 = select i1 %13, double %12, double %9
%15 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %8
17: ; preds = %8, %1
%18 = phi double [ %5, %1 ], [ %14, %8 ]
ret double %18
}