#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 */
scalar_t__ ceil(double);
int calc_interval(int duration) {
  double dd = (double)duration;
  int d, interval;
  d = (int)ceil(dd / 3600);
  if (d <= 24) {
    interval = d * 30;
    return (interval < 600 ? interval : 600);
  }
  d = (int)ceil(dd / 3600 / 24);
  if (d <= 7) {
    interval = d * 600;
    return (interval < 3600 ? interval : 3600);
  }
  if (d <= 31) {
    return (14400);
  }
  d = (int)ceil(dd / 3600 / 24 / 31);
  if (d <= 12) {
    interval = d * 14400;
    return (interval < 86400 ? interval : 86400);
  }
  d = (int)ceil(dd / 3600 / 24 / 366);
  interval = d * 86400;
  return (interval);
}


x86 assembly (clang, -O0):
<calc_interval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xece(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x18,-0x14(%rbp)
jg     117f <calc_interval+0x6f>
imul   $0x1e,-0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x258,-0x18(%rbp)
jge    1167 <calc_interval+0x57>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1174 <calc_interval+0x64>
mov    $0x258,%eax
mov    %eax,-0x1c(%rbp)
jmp    1174 <calc_interval+0x64>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12b4 <calc_interval+0x1a4>
movsd  -0x10(%rbp),%xmm0
movsd  0xe74(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe70(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jg     11e8 <calc_interval+0xd8>
imul   $0x258,-0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xe10,-0x18(%rbp)
jge    11d0 <calc_interval+0xc0>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11dd <calc_interval+0xcd>
mov    $0xe10,%eax
mov    %eax,-0x20(%rbp)
jmp    11dd <calc_interval+0xcd>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12b4 <calc_interval+0x1a4>
cmpl   $0x1f,-0x14(%rbp)
jg     11fe <calc_interval+0xee>
movl   $0x3840,-0x4(%rbp)
jmp    12b4 <calc_interval+0x1a4>
movsd  -0x10(%rbp),%xmm0
movsd  0xdf5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xdf1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xded(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jg     1273 <calc_interval+0x163>
imul   $0x3840,-0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x15180,-0x18(%rbp)
jge    125b <calc_interval+0x14b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1268 <calc_interval+0x158>
mov    $0x15180,%eax
mov    %eax,-0x24(%rbp)
jmp    1268 <calc_interval+0x158>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12b4 <calc_interval+0x1a4>
movsd  -0x10(%rbp),%xmm0
movsd  0xd80(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd7c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd80(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,-0x14(%rbp)
imul   $0x15180,-0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_interval>:
push   %rax
cvtsi2sd %edi,%xmm0
divsd  0xee3(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1030 <ceil@plt>
cmp    $0x18,%eax
jg     1142 <calc_interval+0x32>
mov    %eax,%ecx
shl    $0x5,%ecx
sub    %eax,%ecx
sub    %eax,%ecx
cmp    $0x258,%ecx
mov    $0x258,%eax
jmp    11a6 <calc_interval+0x96>
movsd  (%rsp),%xmm0
divsd  0xeb9(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1030 <ceil@plt>
mov    %rax,%rcx
cmp    $0x7,%ecx
jg     1174 <calc_interval+0x64>
imul   $0x258,%ecx,%ecx
cmp    $0xe10,%ecx
mov    $0xe10,%eax
jmp    11a6 <calc_interval+0x96>
mov    $0x3840,%eax
cmp    $0x20,%ecx
jb     11c3 <calc_interval+0xb3>
movsd  (%rsp),%xmm0
divsd  0xe85(%rip),%xmm0
call   1030 <ceil@plt>
cmp    $0xc,%eax
jg     11ab <calc_interval+0x9b>
imul   $0x3840,%eax,%ecx
cmp    $0x15180,%ecx
mov    $0x15180,%eax
cmovl  %ecx,%eax
pop    %rcx
ret
movsd  (%rsp),%xmm0
divsd  0xe60(%rip),%xmm0
call   1030 <ceil@plt>
imul   $0x15180,%eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @calc_interval(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
%7 = load i32, i32* %3
%8 = sitofp i32 %7 to double
store double %8, double* %4
%9 = load double, double* %4
%10 = fdiv double %9, 3.600000e+03
%11 = call i64 @ceil(double %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp sle i32 %13, 24
br i1 %14, label %15, label %25
15: ; preds = %1
%16 = load i32, i32* %5
%17 = mul nsw i32 %16, 30
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 600
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = load i32, i32* %6
br label %23
22: ; preds = %15
br label %23
23: ; preds = %22, %20
%24 = phi i32 [ %21, %20 ], [ 600, %22 ]
store i32 %24, i32* %2
br label %76
25: ; preds = %1
%26 = load double, double* %4
%27 = fdiv double %26, 3.600000e+03
%28 = fdiv double %27, 2.400000e+01
%29 = call i64 @ceil(double %28)
%30 = trunc i64 %29 to i32
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = icmp sle i32 %31, 7
br i1 %32, label %33, label %43
33: ; preds = %25
%34 = load i32, i32* %5
%35 = mul nsw i32 %34, 600
store i32 %35, i32* %6
%36 = load i32, i32* %6
%37 = icmp slt i32 %36, 3600
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = load i32, i32* %6
br label %41
40: ; preds = %33
br label %41
41: ; preds = %40, %38
%42 = phi i32 [ %39, %38 ], [ 3600, %40 ]
store i32 %42, i32* %2
br label %76
43: ; preds = %25
%44 = load i32, i32* %5
%45 = icmp sle i32 %44, 31
br i1 %45, label %46, label %47
46: ; preds = %43
store i32 14400, i32* %2
br label %76
47: ; preds = %43
%48 = load double, double* %4
%49 = fdiv double %48, 3.600000e+03
%50 = fdiv double %49, 2.400000e+01
%51 = fdiv double %50, 3.100000e+01
%52 = call i64 @ceil(double %51)
%53 = trunc i64 %52 to i32
store i32 %53, i32* %5
%54 = load i32, i32* %5
%55 = icmp sle i32 %54, 12
br i1 %55, label %56, label %66
56: ; preds = %47
%57 = load i32, i32* %5
%58 = mul nsw i32 %57, 14400
store i32 %58, i32* %6
%59 = load i32, i32* %6
%60 = icmp slt i32 %59, 86400
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = load i32, i32* %6
br label %64
63: ; preds = %56
br label %64
64: ; preds = %63, %61
%65 = phi i32 [ %62, %61 ], [ 86400, %63 ]
store i32 %65, i32* %2
br label %76
66: ; preds = %47
%67 = load double, double* %4
%68 = fdiv double %67, 3.600000e+03
%69 = fdiv double %68, 2.400000e+01
%70 = fdiv double %69, 3.660000e+02
%71 = call i64 @ceil(double %70)
%72 = trunc i64 %71 to i32
store i32 %72, i32* %5
%73 = load i32, i32* %5
%74 = mul nsw i32 %73, 86400
store i32 %74, i32* %6
%75 = load i32, i32* %6
store i32 %75, i32* %2
br label %76
76: ; preds = %66, %64, %46, %41, %23
%77 = load i32, i32* %2
ret i32 %77
}

LLVM IR (-O2):
define i32 @calc_interval(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = fdiv double %2, 3.600000e+03
%4 = tail call i64 @ceil(double %3)
%5 = trunc i64 %4 to i32
%6 = icmp slt i32 %5, 25
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = mul nsw i32 %5, 30
%9 = icmp slt i32 %8, 600
%10 = select i1 %9, i32 %8, i32 600
br label %36
11: ; preds = %1
%12 = fdiv double %3, 2.400000e+01
%13 = tail call i64 @ceil(double %12)
%14 = trunc i64 %13 to i32
%15 = icmp slt i32 %14, 8
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = mul nsw i32 %14, 600
%18 = icmp slt i32 %17, 3600
%19 = select i1 %18, i32 %17, i32 3600
br label %36
20: ; preds = %11
%21 = icmp ult i32 %14, 32
br i1 %21, label %36, label %22
22: ; preds = %20
%23 = fdiv double %12, 3.100000e+01
%24 = tail call i64 @ceil(double %23)
%25 = trunc i64 %24 to i32
%26 = icmp slt i32 %25, 13
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = mul nsw i32 %25, 14400
%29 = icmp slt i32 %28, 86400
%30 = select i1 %29, i32 %28, i32 86400
br label %36
31: ; preds = %22
%32 = fdiv double %12, 3.660000e+02
%33 = tail call i64 @ceil(double %32)
%34 = trunc i64 %33 to i32
%35 = mul nsw i32 %34, 86400
br label %36
36: ; preds = %20, %31, %27, %16, %7
%37 = phi i32 [ %10, %7 ], [ %19, %16 ], [ %30, %27 ], [ %35, %31 ], [ 14400, %20 ]
ret i32 %37
}