#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 char_to_int(char);
int /*<<< orphan*/ printf(char *, int);
int main() {
  char *longnumber = "73167176531330624919225119674426574742355349194934"
                     "96983520312774506326239578318016984801869478851843"
                     "85861560789112949495459501737958331952853208805511"
                     "12540698747158523863050715693290963295227443043557"
                     "66896648950445244523161731856403098711121722383113"
                     "62229893423380308135336276614282806444486645238749"
                     "30358907296290491560440772390713810515859307960866"
                     "70172427121883998797908792274921901699720888093776"
                     "65727333001053367881220235421809751254540594752243"
                     "52584907711670556013604839586446706324415722155397"
                     "53697817977846174064955149290862569321978468622482"
                     "83972241375657056057490261407972968652414535100474"
                     "82166370484403199890008895243450658541227588666881"
                     "16427171479924442928230863465674813919123162824586"
                     "17866458359124566529476545682848912883142607690042"
                     "24219022671055626321111109370544217506941658960408"
                     "07198403850962455444362981230987879927244284909188"
                     "84580156166097919133875499200524063689912560717606"
                     "05886116467109405077541002256983155200055935729725"
                     "71636269561882670428252483600823257530420752963450";
  int product = 0;
  char *c1, *c2, *c3, *c4, *c5;
  int tempproduct;
  c1 = longnumber;
  c2 = longnumber + 1;
  c3 = longnumber + 2;
  c4 = longnumber + 3;
  c5 = longnumber + 4;
  while (*c5 != '\0') {
    tempproduct = 1;
    tempproduct *= char_to_int(*c1);
    tempproduct *= char_to_int(*c2);
    tempproduct *= char_to_int(*c3);
    tempproduct *= char_to_int(*c4);
    tempproduct *= char_to_int(*c5);
    if (tempproduct > product)
      product = tempproduct;
    c1++;
    c2++;
    c3++;
    c4++;
    c5++;
  }
  printf("PRODUCT: %d\n", product);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1242 <main+0x122>
movl   $0x1,-0x44(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <char_to_int@plt>
imul   -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1040 <char_to_int@plt>
imul   -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1040 <char_to_int@plt>
imul   -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%edi
call   1040 <char_to_int@plt>
imul   -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%edi
call   1040 <char_to_int@plt>
imul   -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1201 <main+0xe1>
mov    -0x44(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1179 <main+0x59>
mov    -0x14(%rbp),%esi
lea    0x119d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
lea    0xed4(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%r12d
movsbl -0x5(%rbp),%edi
call   1040 <char_to_int@plt>
mov    %eax,%ebx
movsbl -0x4(%rbp),%edi
call   1040 <char_to_int@plt>
mov    %eax,%r15d
imul   %ebx,%r15d
movsbl -0x3(%rbp),%edi
call   1040 <char_to_int@plt>
mov    %eax,%r14d
movsbl -0x2(%rbp),%edi
call   1040 <char_to_int@plt>
mov    %eax,%ebx
imul   %r14d,%ebx
imul   %r15d,%ebx
movsbl -0x1(%rbp),%edi
call   1040 <char_to_int@plt>
imul   %ebx,%eax
cmp    %r12d,%eax
cmovle %r12d,%eax
cmpb   $0x0,0x0(%rbp)
lea    0x1(%rbp),%rbp
jne    1140 <main+0x20>
lea    0x1248(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1001 x i8] c"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\00"
@.str.1 = [13 x i8] c"PRODUCT: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([1001 x i8], [1001 x i8]* @.str, i64 0, i64 0), i8** %2
store i32 0, i32* %3
%10 = load i8*, i8** %2
store i8* %10, i8** %4
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 1
store i8* %12, i8** %5
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 2
store i8* %14, i8** %6
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 3
store i8* %16, i8** %7
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 4
store i8* %18, i8** %8
br label %19
19: ; preds = %55, %0
%20 = load i8*, i8** %8
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %66
24: ; preds = %19
store i32 1, i32* %9
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = call i32 @char_to_int(i8 signext %26)
%28 = load i32, i32* %9
%29 = mul nsw i32 %28, %27
store i32 %29, i32* %9
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = call i32 @char_to_int(i8 signext %31)
%33 = load i32, i32* %9
%34 = mul nsw i32 %33, %32
store i32 %34, i32* %9
%35 = load i8*, i8** %6
%36 = load i8, i8* %35
%37 = call i32 @char_to_int(i8 signext %36)
%38 = load i32, i32* %9
%39 = mul nsw i32 %38, %37
store i32 %39, i32* %9
%40 = load i8*, i8** %7
%41 = load i8, i8* %40
%42 = call i32 @char_to_int(i8 signext %41)
%43 = load i32, i32* %9
%44 = mul nsw i32 %43, %42
store i32 %44, i32* %9
%45 = load i8*, i8** %8
%46 = load i8, i8* %45
%47 = call i32 @char_to_int(i8 signext %46)
%48 = load i32, i32* %9
%49 = mul nsw i32 %48, %47
store i32 %49, i32* %9
%50 = load i32, i32* %9
%51 = load i32, i32* %3
%52 = icmp sgt i32 %50, %51
br i1 %52, label %53, label %55
53: ; preds = %24
%54 = load i32, i32* %9
store i32 %54, i32* %3
br label %55
55: ; preds = %53, %24
%56 = load i8*, i8** %4
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %4
%58 = load i8*, i8** %5
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %5
%60 = load i8*, i8** %6
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %6
%62 = load i8*, i8** %7
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %7
%64 = load i8*, i8** %8
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %8
br label %19
66: ; preds = %19
%67 = load i32, i32* %3
%68 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %67)
ret i32 0
}

LLVM IR (-O2):
@.str = [1001 x i8] c"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\00"
@.str.1 = [13 x i8] c"PRODUCT: %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i8* [ getelementptr inbounds ([1001 x i8], [1001 x i8]* @.str, i64 0, i64 4), %0 ], [ %28, %1 ]
%3 = phi i8* [ getelementptr inbounds ([1001 x i8], [1001 x i8]* @.str, i64 0, i64 3), %0 ], [ %27, %1 ]
%4 = phi i8* [ getelementptr inbounds ([1001 x i8], [1001 x i8]* @.str, i64 0, i64 2), %0 ], [ %26, %1 ]
%5 = phi i8* [ getelementptr inbounds ([1001 x i8], [1001 x i8]* @.str, i64 0, i64 1), %0 ], [ %25, %1 ]
%6 = phi i8* [ getelementptr inbounds ([1001 x i8], [1001 x i8]* @.str, i64 0, i64 0), %0 ], [ %24, %1 ]
%7 = phi i32 [ 0, %0 ], [ %23, %1 ]
%8 = load i8, i8* %6
%9 = tail call i32 @char_to_int(i8 signext %8)
%10 = load i8, i8* %5
%11 = tail call i32 @char_to_int(i8 signext %10)
%12 = mul nsw i32 %11, %9
%13 = load i8, i8* %4
%14 = tail call i32 @char_to_int(i8 signext %13)
%15 = mul nsw i32 %12, %14
%16 = load i8, i8* %3
%17 = tail call i32 @char_to_int(i8 signext %16)
%18 = mul nsw i32 %15, %17
%19 = load i8, i8* %2
%20 = tail call i32 @char_to_int(i8 signext %19)
%21 = mul nsw i32 %18, %20
%22 = icmp sgt i32 %21, %7
%23 = select i1 %22, i32 %21, i32 %7
%24 = getelementptr inbounds i8, i8* %6, i64 1
%25 = getelementptr inbounds i8, i8* %5, i64 1
%26 = getelementptr inbounds i8, i8* %4, i64 1
%27 = getelementptr inbounds i8, i8* %3, i64 1
%28 = getelementptr inbounds i8, i8* %2, i64 1
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %1
31: ; preds = %1
%32 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}