#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 */
struct timeb {
  long millitm;
};

/* Variables and functions */
int /*<<< orphan*/ ftime(struct timeb *);
int htoi_bin(char *);
int htoi_hex(char *);
int htoi_oct(char *);
int moltiplication(int, int);
double power(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ show_limits();
void test_math(void) {
  struct timeb time;
  ftime(&time);
  long t = time.millitm;
  int c = moltiplication(123123, 123123);
  ftime(&time);
  printf("%d in %d\n", c, (time.millitm - t));
  ftime(&time);
  t = time.millitm;
  c = 123123 * 123123;
  printf("%d in %d", c, (time.millitm - t));
  show_limits();
  int b = 12;
  int e = 2;
  printf("power %d^%d: %g\n", b, e, power(b, e));
  char *n_bin = "1010011";
  printf("%s\t(bin -> int)\t%d\n", n_bin, htoi_bin(n_bin));
  char *n_oct = "0012";
  printf("%s\t(oct -> int)\t%d\n", n_oct, htoi_oct(n_oct));
  char *n_hex = "0xFF";
  printf("%s\t(hex -> int)\t%d\n", n_hex, htoi_hex(n_hex));
}


x86 assembly (clang, -O0):
<test_math>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x8(%rbp),%rdi
call   1090 <ftime@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x1e0f3,%esi
mov    %esi,%edi
call   1060 <moltiplication@plt>
mov    %eax,-0x14(%rbp)
lea    -0x8(%rbp),%rdi
call   1090 <ftime@plt>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rdx
sub    -0x10(%rbp),%rdx
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1090 <ftime@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x879026a9,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rdx
sub    -0x10(%rbp),%rdx
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <show_limits@plt>
movl   $0xc,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <power@plt>
mov    -0x58(%rbp),%esi
mov    -0x54(%rbp),%edx
lea    0xddf(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xde2(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <htoi_bin@plt>
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdce(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <htoi_oct@plt>
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdb7(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   10a0 <htoi_hex@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_math>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1090 <ftime@plt>
mov    0x8(%rsp),%rbx
mov    $0x1e0f3,%edi
mov    $0x1e0f3,%esi
call   1060 <moltiplication@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1090 <ftime@plt>
mov    0x8(%rsp),%rdx
sub    %rbx,%rdx
lea    0xe3e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1090 <ftime@plt>
lea    0xe30(%rip),%rdi
mov    $0x879026a9,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <show_limits@plt>
mov    $0xc,%edi
mov    $0x2,%esi
call   1030 <power@plt>
lea    0xe0e(%rip),%rdi
mov    $0xc,%esi
mov    $0x2,%edx
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe07(%rip),%rbx
mov    %rbx,%rdi
call   1080 <htoi_bin@plt>
lea    0xe00(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe01(%rip),%rbx
mov    %rbx,%rdi
call   1050 <htoi_oct@plt>
lea    0xdf7(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdf8(%rip),%rbx
mov    %rbx,%rdi
call   10a0 <htoi_hex@plt>
lea    0xdee(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeb = type { i64 }
@.str = [10 x i8] c"%d in %d\0A\00"
@.str.1 = [9 x i8] c"%d in %d\00"
@.str.2 = [17 x i8] c"power %d^%d: %g\0A\00"
@.str.3 = [8 x i8] c"1010011\00"
@.str.4 = [20 x i8] c"%s\09(bin -> int)\09%d\0A\00"
@.str.5 = [5 x i8] c"0012\00"
@.str.6 = [20 x i8] c"%s\09(oct -> int)\09%d\0A\00"
@.str.7 = [5 x i8] c"0xFF\00"
@.str.8 = [20 x i8] c"%s\09(hex -> int)\09%d\0A\00"
define void @test_math() {
%1 = alloca %struct.timeb
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = call i32 @ftime(%struct.timeb* %1)
%10 = getelementptr inbounds %struct.timeb, %struct.timeb* %1, i32 0, i32 0
%11 = load i64, i64* %10
store i64 %11, i64* %2
%12 = call i32 @moltiplication(i32 123123, i32 123123)
store i32 %12, i32* %3
%13 = call i32 @ftime(%struct.timeb* %1)
%14 = load i32, i32* %3
%15 = getelementptr inbounds %struct.timeb, %struct.timeb* %1, i32 0, i32 0
%16 = load i64, i64* %15
%17 = load i64, i64* %2
%18 = sub nsw i64 %16, %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %14, i64 %18)
%20 = call i32 @ftime(%struct.timeb* %1)
%21 = getelementptr inbounds %struct.timeb, %struct.timeb* %1, i32 0, i32 0
%22 = load i64, i64* %21
store i64 %22, i64* %2
store i32 -2020596055, i32* %3
%23 = load i32, i32* %3
%24 = getelementptr inbounds %struct.timeb, %struct.timeb* %1, i32 0, i32 0
%25 = load i64, i64* %24
%26 = load i64, i64* %2
%27 = sub nsw i64 %25, %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %23, i64 %27)
%29 = call i32 (...) @show_limits()
store i32 12, i32* %4
store i32 2, i32* %5
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = call double @power(i32 %32, i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %31, double %34)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %6
%36 = load i8*, i8** %6
%37 = load i8*, i8** %6
%38 = call i32 @htoi_bin(i8* %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %36, i32 %38)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %7
%40 = load i8*, i8** %7
%41 = load i8*, i8** %7
%42 = call i32 @htoi_oct(i8* %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %40, i32 %42)
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %8
%44 = load i8*, i8** %8
%45 = load i8*, i8** %8
%46 = call i32 @htoi_hex(i8* %45)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %44, i32 %46)
ret void
}

LLVM IR (-O2):
%struct.timeb = type { i64 }
@.str = [10 x i8] c"%d in %d\0A\00"
@.str.1 = [9 x i8] c"%d in %d\00"
@.str.2 = [17 x i8] c"power %d^%d: %g\0A\00"
@.str.3 = [8 x i8] c"1010011\00"
@.str.4 = [20 x i8] c"%s\09(bin -> int)\09%d\0A\00"
@.str.5 = [5 x i8] c"0012\00"
@.str.6 = [20 x i8] c"%s\09(oct -> int)\09%d\0A\00"
@.str.7 = [5 x i8] c"0xFF\00"
@.str.8 = [20 x i8] c"%s\09(hex -> int)\09%d\0A\00"
define void @test_math() {
%1 = alloca %struct.timeb
%2 = bitcast %struct.timeb* %1 to i8*
%3 = call i32 @ftime(%struct.timeb* %1)
%4 = getelementptr inbounds %struct.timeb, %struct.timeb* %1, i64 0, i32 0
%5 = load i64, i64* %4
%6 = call i32 @moltiplication(i32 123123, i32 123123)
%7 = call i32 @ftime(%struct.timeb* %1)
%8 = load i64, i64* %4
%9 = sub nsw i64 %8, %5
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %6, i64 %9)
%11 = call i32 @ftime(%struct.timeb* %1)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 -2020596055, i64 0)
%13 = call i32 (...) @show_limits()
%14 = call double @power(i32 12, i32 2)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 12, i32 2, double %14)
%16 = call i32 @htoi_bin(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = call i32 @htoi_oct(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %18)
%20 = call i32 @htoi_hex(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %20)
ret void
}