#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 timeval {
  unsigned long long tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, unsigned long long);
int main(void) {
  struct timeval stop, start;
  gettimeofday(&start, NULL);
  unsigned long long mult = 1, max = 0;
  int chars;
  char *thousandDigit =
      "731671765313306249192251196744265747423553491949349698352031277450632623"
      "957831801698480186947885184385861560789112949495459501737958331952853208"
      "805511125406987471585238630507156932909632952274430435576689664895044524"
      "452316173185640309871112172238311362229893423380308135336276614282806444"
      "486645238749303589072962904915604407723907138105158593079608667017242712"
      "188399879790879227492190169972088809377665727333001053367881220235421809"
      "751254540594752243525849077116705560136048395864467063244157221553975369"
      "781797784617406495514929086256932197846862248283972241375657056057490261"
      "407972968652414535100474821663704844031998900088952434506585412275886668"
      "811642717147992444292823086346567481391912316282458617866458359124566529"
      "476545682848912883142607690042242190226710556263211111093705442175069416"
      "589604080719840385096245544436298123098787992724428490918884580156166097"
      "919133875499200524063689912560717606058861164671094050775410022569831552"
      "0005593572972571636269561882670428252483600823257530420752963450";
  while (*(thousandDigit + 12) != '\x0') {
    mult = 1;
    for (chars = 0; chars < 13; chars++) {
      mult = (unsigned long long)mult * (*(thousandDigit + chars) - '0');
    }
    if (mult > max) {
      max = (unsigned long long)mult;
    }
    thousandDigit++;
  }
  printf("the max number is: %lld", max);
  gettimeofday(&stop, NULL);
  printf("\ntook %lu usec\n", stop.tv_usec - start.tv_usec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movq   $0x1,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xead(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl 0xc(%rax),%eax
cmp    $0x0,%eax
je     11d4 <main+0xb4>
movq   $0x1,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xd,-0x2c(%rbp)
jge    11ad <main+0x8d>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    $0x30,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1177 <main+0x57>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jbe    11c3 <main+0xa3>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1157 <main+0x37>
mov    -0x28(%rbp),%rsi
lea    0x120a(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x10(%rbp),%rsi
sub    -0x18(%rbp),%rsi
lea    0x1201(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    $0x37,%cl
lea    0xed3(%rip),%rax
nopw   0x0(%rax,%rax,1)
mov    %rbx,%r8
movsbq %cl,%rsi
add    $0xffffffffffffffd0,%rsi
movsbq -0xc(%rax),%rcx
mov    %rcx,%rdi
add    $0xffffffffffffffd0,%rdi
imul   %rsi,%rdi
movsbq -0xb(%rax),%rsi
add    $0xffffffffffffffd0,%rsi
movsbq -0xa(%rax),%rbx
add    $0xffffffffffffffd0,%rbx
imul   %rsi,%rbx
imul   %rdi,%rbx
movsbq -0x9(%rax),%rsi
add    $0xffffffffffffffd0,%rsi
movsbq -0x8(%rax),%rdi
add    $0xffffffffffffffd0,%rdi
imul   %rsi,%rdi
movsbq -0x7(%rax),%rsi
add    $0xffffffffffffffd0,%rsi
imul   %rdi,%rsi
imul   %rbx,%rsi
movsbq -0x6(%rax),%rdi
add    $0xffffffffffffffd0,%rdi
movsbq -0x5(%rax),%rbx
add    $0xffffffffffffffd0,%rbx
imul   %rdi,%rbx
movsbq -0x4(%rax),%rdi
add    $0xffffffffffffffd0,%rdi
imul   %rbx,%rdi
movsbq -0x3(%rax),%rdx
add    $0xffffffffffffffd0,%rdx
imul   %rdi,%rdx
imul   %rsi,%rdx
movsbq -0x2(%rax),%rsi
add    $0xffffffffffffffd0,%rsi
movsbq -0x1(%rax),%rbx
add    $0xffffffffffffffd0,%rbx
imul   %rsi,%rbx
imul   %rdx,%rbx
cmp    %r8,%rbx
cmovbe %r8,%rbx
cmpb   $0x0,(%rax)
lea    0x1(%rax),%rax
jne    1140 <main+0x20>
lea    0x11e4(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x8(%rsp),%rsi
sub    (%rsp),%rsi
lea    0x11d8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i64 }
@.str = [1001 x i8] c"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\00"
@.str.1 = [24 x i8] c"the max number is: %lld\00"
@.str.2 = [16 x i8] c"\0Atook %lu usec\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %1
%8 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
store i64 1, i64* %4
store i64 0, i64* %5
store i8* getelementptr inbounds ([1001 x i8], [1001 x i8]* @.str, i64 0, i64 0), i8** %7
br label %9
9: ; preds = %39, %0
%10 = load i8*, i8** %7
%11 = getelementptr inbounds i8, i8* %10, i64 12
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %42
15: ; preds = %9
store i64 1, i64* %4
store i32 0, i32* %6
br label %16
16: ; preds = %30, %15
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 13
br i1 %18, label %19, label %33
19: ; preds = %16
%20 = load i64, i64* %4
%21 = load i8*, i8** %7
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = sub nsw i32 %26, 48
%28 = sext i32 %27 to i64
%29 = mul i64 %20, %28
store i64 %29, i64* %4
br label %30
30: ; preds = %19
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %16
33: ; preds = %16
%34 = load i64, i64* %4
%35 = load i64, i64* %5
%36 = icmp ugt i64 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load i64, i64* %4
store i64 %38, i64* %5
br label %39
39: ; preds = %37, %33
%40 = load i8*, i8** %7
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %7
br label %9
42: ; preds = %9
%43 = load i64, i64* %5
%44 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 %43)
%45 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%47 = load i64, i64* %46
%48 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%49 = load i64, i64* %48
%50 = sub i64 %47, %49
%51 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i64 %50)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i64 }
@.str = [1001 x i8] c"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\00"
@.str.1 = [24 x i8] c"the max number is: %lld\00"
@.str.2 = [16 x i8] c"\0Atook %lu usec\0A\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
br label %6
6: ; preds = %0, %6
%7 = phi i8 [ 55, %0 ], [ %13, %6 ]
%8 = phi i8* [ getelementptr inbounds ([1001 x i8], [1001 x i8]* @.str, i64 0, i64 0), %0 ], [ %12, %6 ]
%9 = phi i64 [ 0, %0 ], [ %73, %6 ]
%10 = sext i8 %7 to i64
%11 = add nsw i64 %10, -48
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i64
%15 = add nsw i64 %14, -48
%16 = mul nsw i64 %15, %11
%17 = getelementptr inbounds i8, i8* %8, i64 2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i64
%20 = add nsw i64 %19, -48
%21 = mul nsw i64 %20, %16
%22 = getelementptr inbounds i8, i8* %8, i64 3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i64
%25 = add nsw i64 %24, -48
%26 = mul nsw i64 %25, %21
%27 = getelementptr inbounds i8, i8* %8, i64 4
%28 = load i8, i8* %27
%29 = sext i8 %28 to i64
%30 = add nsw i64 %29, -48
%31 = mul nsw i64 %30, %26
%32 = getelementptr inbounds i8, i8* %8, i64 5
%33 = load i8, i8* %32
%34 = sext i8 %33 to i64
%35 = add nsw i64 %34, -48
%36 = mul nsw i64 %35, %31
%37 = getelementptr inbounds i8, i8* %8, i64 6
%38 = load i8, i8* %37
%39 = sext i8 %38 to i64
%40 = add nsw i64 %39, -48
%41 = mul nsw i64 %40, %36
%42 = getelementptr inbounds i8, i8* %8, i64 7
%43 = load i8, i8* %42
%44 = sext i8 %43 to i64
%45 = add nsw i64 %44, -48
%46 = mul nsw i64 %45, %41
%47 = getelementptr inbounds i8, i8* %8, i64 8
%48 = load i8, i8* %47
%49 = sext i8 %48 to i64
%50 = add nsw i64 %49, -48
%51 = mul i64 %50, %46
%52 = getelementptr inbounds i8, i8* %8, i64 9
%53 = load i8, i8* %52
%54 = sext i8 %53 to i64
%55 = add nsw i64 %54, -48
%56 = mul i64 %55, %51
%57 = getelementptr inbounds i8, i8* %8, i64 10
%58 = load i8, i8* %57
%59 = sext i8 %58 to i64
%60 = add nsw i64 %59, -48
%61 = mul i64 %60, %56
%62 = getelementptr inbounds i8, i8* %8, i64 11
%63 = load i8, i8* %62
%64 = sext i8 %63 to i64
%65 = add nsw i64 %64, -48
%66 = mul i64 %65, %61
%67 = getelementptr inbounds i8, i8* %8, i64 12
%68 = load i8, i8* %67
%69 = sext i8 %68 to i64
%70 = add nsw i64 %69, -48
%71 = mul i64 %70, %66
%72 = icmp ugt i64 %71, %9
%73 = select i1 %72, i64 %71, i64 %9
%74 = getelementptr inbounds i8, i8* %8, i64 13
%75 = load i8, i8* %74
%76 = icmp eq i8 %75, 0
br i1 %76, label %77, label %6
77: ; preds = %6
%78 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i64 %73)
%79 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%80 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%81 = load i64, i64* %80
%82 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%83 = load i64, i64* %82
%84 = sub i64 %81, %83
%85 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i64 %84)
ret i32 0
}