#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 /*<<< orphan*/ printf(char *, int, ...);
int main() {
  long l = 0;
  int sec = 123345;
  int usec = 1234;
  printf("sec %d usec %d\n", sec, usec);
  l = sec * 10000000 + usec;
  printf("l %ld\n", l);
  int rusec = l % 10000000;
  int rsec = l / 10000000;
  printf("rsec %d rusec %d\n", rsec, rusec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x1e1d1,-0x14(%rbp)
movl   $0x4d2,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
imul   $0x989680,-0x14(%rbp),%eax
add    -0x18(%rbp),%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    $0x989680,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x989680,%ecx
cqto
idiv   %rcx
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x1e1d1,%esi
mov    $0x4d2,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x2f596352,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x4f,%esi
mov    $0x42f1d2,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"sec %d usec %d\0A\00"
@.str.1 = [7 x i8] c"l %ld\0A\00"
@.str.2 = [18 x i8] c"rsec %d rusec %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %2
store i32 123345, i32* %3
store i32 1234, i32* %4
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = load i32, i32* %3
%11 = mul nsw i32 %10, 10000000
%12 = load i32, i32* %4
%13 = add nsw i32 %11, %12
%14 = sext i32 %13 to i64
store i64 %14, i64* %2
%15 = load i64, i64* %2
%16 = trunc i64 %15 to i32
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i64, i64* %2
%19 = srem i64 %18, 10000000
%20 = trunc i64 %19 to i32
store i32 %20, i32* %5
%21 = load i64, i64* %2
%22 = sdiv i64 %21, 10000000
%23 = trunc i64 %22 to i32
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = load i32, i32* %5
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"sec %d usec %d\0A\00"
@.str.1 = [7 x i8] c"l %ld\0A\00"
@.str.2 = [18 x i8] c"rsec %d rusec %d\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 123345, i32 1234)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 794387282)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 79, i32 4387282)
ret i32 0
}