#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ tprintf(char *, int);
int get_seed_old() {
  time_t clock;
  struct tm *lt;
  time_t tloc;
  int ihour, imin, isec, seed;
  clock = time(&tloc);
  lt = localtime(&clock);
  ihour = lt->tm_hour;
  if (ihour > 12)
    ihour -= 12;
  ihour--;
  imin = lt->tm_min;
  isec = lt->tm_sec;
  seed = isec + 60 * (imin + 60 * ihour);
  seed = (int)((double)(seed / (60.0 * 60.0 * 12.0)) * 2147483647);
  if (seed <= 0)
    seed = 1;
  tprintf("Seed: %d\n", seed);
  return seed;
}


x86 assembly (clang, -O0):
<get_seed_old>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x14(%rbp),%rdi
call   1050 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xc,-0x18(%rbp)
jle    116d <get_seed_old+0x3d>
mov    -0x18(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   $0x3c,-0x18(%rbp),%edx
add    %edx,%ecx
imul   $0x3c,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe49(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jg     11d3 <get_seed_old+0xa3>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe33(%rip),%rdi
call   1040 <tprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_seed_old>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1050 <time@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%ecx
mov    0x8(%rax),%edx
lea    -0xc(%rcx),%esi
cmp    $0xd,%ecx
cmovl  %ecx,%esi
imul   $0x3c,%esi,%ecx
add    0x4(%rax),%ecx
imul   $0x3c,%ecx,%eax
add    %edx,%eax
add    $0xfffff1f0,%eax
cvtsi2sd %eax,%xmm0
divsd  0xe89(%rip),%xmm0
mulsd  0xe89(%rip),%xmm0
cvttsd2si %xmm0,%eax
test   %eax,%eax
mov    $0x1,%ebx
cmovg  %eax,%ebx
lea    0xe7c(%rip),%rdi
mov    %ebx,%esi
call   1040 <tprintf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@.str = [10 x i8] c"Seed: %d\0A\00"
define i32 @get_seed_old() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i32 @time(i32* %3)
store i32 %8, i32* %1
%9 = call %struct.tm* @localtime(i32* %1)
store %struct.tm* %9, %struct.tm** %2
%10 = load %struct.tm*, %struct.tm** %2
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%12 = load i32, i32* %11
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 12
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 12
store i32 %17, i32* %4
br label %18
18: ; preds = %15, %0
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
%21 = load %struct.tm*, %struct.tm** %2
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 1
%23 = load i32, i32* %22
store i32 %23, i32* %5
%24 = load %struct.tm*, %struct.tm** %2
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 2
%26 = load i32, i32* %25
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = load i32, i32* %5
%29 = load i32, i32* %4
%30 = mul nsw i32 60, %29
%31 = add nsw i32 %28, %30
%32 = mul nsw i32 60, %31
%33 = add nsw i32 %27, %32
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = sitofp i32 %34 to double
%36 = fdiv double %35, 4.320000e+04
%37 = fmul double %36, 0x41DFFFFFFFC00000
%38 = fptosi double %37 to i32
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = icmp sle i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %18
store i32 1, i32* %7
br label %42
42: ; preds = %41, %18
%43 = load i32, i32* %7
%44 = call i32 @tprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %7
ret i32 %45
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str = [10 x i8] c"Seed: %d\0A\00"
define i32 @get_seed_old() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @time(i32* %2)
store i32 %5, i32* %1
%6 = call %struct.tm* @localtime(i32* %1)
%7 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 0
%8 = load i32, i32* %7
%9 = icmp sgt i32 %8, 12
%10 = add nsw i32 %8, -12
%11 = select i1 %9, i32 %10, i32 %8
%12 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 2
%15 = load i32, i32* %14
%16 = mul i32 %11, 60
%17 = add i32 %13, -60
%18 = add i32 %17, %16
%19 = mul nsw i32 %18, 60
%20 = add nsw i32 %19, %15
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 4.320000e+04
%23 = fmul double %22, 0x41DFFFFFFFC00000
%24 = fptosi double %23 to i32
%25 = icmp sgt i32 %24, 1
%26 = select i1 %25, i32 %24, i32 1
%27 = call i32 @tprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %26)
ret i32 %26
}