#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 RTTrafficInfo_Get_Avg_Speed(int, int, int);
int roadmap_line_length(int);
int roadmap_math_to_cm(int);
int RTTrafficInfo_Get_Avg_Cross_Time(int line, int square, int against_dir) {
  int speed;
  int length, length_m;
  speed = RTTrafficInfo_Get_Avg_Speed(line, square, against_dir);
  if (speed == 0)
    return 0;
  length = roadmap_line_length(line);
  length_m = roadmap_math_to_cm(length) / 100;
  return (int)(length_m * 3.6 / speed) + 1;
}


x86 assembly (clang, -O0):
<RTTrafficInfo_Get_Avg_Cross_Time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <RTTrafficInfo_Get_Avg_Speed@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1168 <RTTrafficInfo_Get_Avg_Cross_Time+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11aa <RTTrafficInfo_Get_Avg_Cross_Time+0x7a>
mov    -0x8(%rbp),%edi
call   1040 <roadmap_line_length@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <roadmap_math_to_cm@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RTTrafficInfo_Get_Avg_Cross_Time>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
call   1030 <RTTrafficInfo_Get_Avg_Speed@plt>
test   %eax,%eax
je     1181 <RTTrafficInfo_Get_Avg_Cross_Time+0x51>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <roadmap_line_length@plt>
mov    %eax,%edi
call   1050 <roadmap_math_to_cm@plt>
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe90(%rip),%xmm0
cvtsi2sd %ebx,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
jmp    1183 <RTTrafficInfo_Get_Avg_Cross_Time+0x53>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @RTTrafficInfo_Get_Avg_Cross_Time(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = call i32 @RTTrafficInfo_Get_Avg_Speed(i32 %11, i32 %12, i32 %13)
store i32 %14, i32* %8
%15 = load i32, i32* %8
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %3
store i32 0, i32* %4
br label %32
18: ; preds = %3
%19 = load i32, i32* %5
%20 = call i32 @roadmap_line_length(i32 %19)
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = call i32 @roadmap_math_to_cm(i32 %21)
%23 = sdiv i32 %22, 100
store i32 %23, i32* %10
%24 = load i32, i32* %10
%25 = sitofp i32 %24 to double
%26 = fmul double %25, 3.600000e+00
%27 = load i32, i32* %8
%28 = sitofp i32 %27 to double
%29 = fdiv double %26, %28
%30 = fptosi double %29 to i32
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %32
32: ; preds = %18, %17
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @RTTrafficInfo_Get_Avg_Cross_Time(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @RTTrafficInfo_Get_Avg_Speed(i32 %0, i32 %1, i32 %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i32 @roadmap_line_length(i32 %0)
%8 = tail call i32 @roadmap_math_to_cm(i32 %7)
%9 = sdiv i32 %8, 100
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 3.600000e+00
%12 = sitofp i32 %4 to double
%13 = fdiv double %11, %12
%14 = fptosi double %13 to i32
%15 = add nsw i32 %14, 1
br label %16
16: ; preds = %3, %6
%17 = phi i32 [ %15, %6 ], [ 0, %3 ]
ret i32 %17
}