#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
double time2day_percentage(int, int);
double get_percent_of_day(char *time_string) {
  int hour, minute;
  char temp_buffer[3];
  if (strlen(time_string) != 4) {
    fprintf(stderr, "WARNING: get_percent_of_day(%s) must be length 4\n",
            time_string);
    return 0.0;
  }
  *(temp_buffer + 2) = '\0';
  strncpy(temp_buffer, time_string, 2);
  hour = atoi(temp_buffer);
  strncpy(temp_buffer, time_string + 2, 2);
  minute = atoi(temp_buffer);
  return time2day_percentage(hour, minute);
}


x86 assembly (clang, -O0):
<get_percent_of_day>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
je     1194 <get_percent_of_day+0x44>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe7e(%rip),%rsi
call   1060 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e8 <get_percent_of_day+0x98>
movb   $0x0,-0x19(%rbp)
lea    -0x1b(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x2,%edx
call   1040 <strncpy@plt>
lea    -0x1b(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x1b(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x2,%rsi
mov    $0x2,%edx
call   1040 <strncpy@plt>
lea    -0x1b(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <time2day_percentage@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_percent_of_day>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1050 <strlen@plt>
cmp    $0x4,%eax
jne    11b0 <get_percent_of_day+0x60>
movb   $0x0,0xf(%rsp)
lea    0xd(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1040 <strncpy@plt>
mov    %r14,%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
add    $0x2,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1040 <strncpy@plt>
mov    %r14,%rdi
call   1070 <atoi@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1030 <time2day_percentage@plt>
jmp    11cb <get_percent_of_day+0x7b>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
xorps  %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [50 x i8] c"WARNING: get_percent_of_day(%s) must be length 4\0A\00"
define double @get_percent_of_day(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [3 x i8]
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = icmp ne i32 %8, 4
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %3
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %12)
store double 0.000000e+00, double* %2
br label %31
14: ; preds = %1
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds i8, i8* %15, i64 2
store i8 0, i8* %16
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%18 = load i8*, i8** %3
%19 = call i32 @strncpy(i8* %17, i8* %18, i32 2)
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %4
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = call i32 @strncpy(i8* %22, i8* %24, i32 2)
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %5
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = call double @time2day_percentage(i32 %28, i32 %29)
store double %30, double* %2
br label %31
31: ; preds = %14, %10
%32 = load double, double* %2
ret double %32
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [50 x i8] c"WARNING: get_percent_of_day(%s) must be length 4\0A\00"
define double @get_percent_of_day(i8* %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 4
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %17
9: ; preds = %1
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
store i8 0, i8* %10
%11 = call i32 @strncpy(i8* %3, i8* %0, i32 2)
%12 = call i32 @atoi(i8* %3)
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = call i32 @strncpy(i8* %3, i8* %13, i32 2)
%15 = call i32 @atoi(i8* %3)
%16 = call double @time2day_percentage(i32 %12, i32 %15)
br label %17
17: ; preds = %9, %6
%18 = phi double [ 0.000000e+00, %6 ], [ %16, %9 ]
ret double %18
}