#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*/ number_string;

/* Variables and functions */
scalar_t__ digittoint(char);
int /*<<< orphan*/ printf(char *, long long);
void problem_008(void) {
  char number_string[] = "73167176531330624919225119674426574742355349194934"
                         "96983520312774506326239578318016984801869478851843"
                         "85861560789112949495459501737958331952853208805511"
                         "12540698747158523863050715693290963295227443043557"
                         "66896648950445244523161731856403098711121722383113"
                         "62229893423380308135336276614282806444486645238749"
                         "30358907296290491560440772390713810515859307960866"
                         "70172427121883998797908792274921901699720888093776"
                         "65727333001053367881220235421809751254540594752243"
                         "52584907711670556013604839586446706324415722155397"
                         "53697817977846174064955149290862569321978468622482"
                         "83972241375657056057490261407972968652414535100474"
                         "82166370484403199890008895243450658541227588666881"
                         "16427171479924442928230863465674813919123162824586"
                         "17866458359124566529476545682848912883142607690042"
                         "24219022671055626321111109370544217506941658960408"
                         "07198403850962455444362981230987879927244284909188"
                         "84580156166097919133875499200524063689912560717606"
                         "05886116467109405077541002256983155200055935729725"
                         "71636269561882670428252483600823257530420752963450";
  int n = 13;
  long long largest = 0;
  long long product;
  int i, j;
  for (i = 0; i <= sizeof(number_string) - (n + 2); i++) {
    product = 1;
    for (j = 0; j <= n - 1; j++) {
      product *= (long long)digittoint(number_string[i + j]);
    }
    if (product > largest) {
      largest = product;
    }
  }
  printf("%llu", largest);
  return;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    -0x3f0(%rbp),%rdi
lea    0xeb7(%rip),%rsi
mov    $0x3e9,%edx
call   1040 <memcpy@plt>
movl   $0xd,-0x3f4(%rbp)
movq   $0x0,-0x400(%rbp)
movl   $0x0,-0x40c(%rbp)
movslq -0x40c(%rbp),%rax
mov    -0x3f4(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rdx
mov    $0x3e9,%ecx
sub    %rdx,%rcx
cmp    %rcx,%rax
ja     123b <problem_008+0x10b>
movq   $0x1,-0x408(%rbp)
movl   $0x0,-0x410(%rbp)
mov    -0x410(%rbp),%eax
mov    -0x3f4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1200 <problem_008+0xd0>
mov    -0x40c(%rbp),%eax
add    -0x410(%rbp),%eax
cltq
movsbl -0x3f0(%rbp,%rax,1),%edi
ff
call   1050 <digittoint@plt>
imul   -0x408(%rbp),%rax
ff
mov    %rax,-0x408(%rbp)
mov    -0x410(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x410(%rbp)
jmp    11ab <problem_008+0x7b>
mov    -0x408(%rbp),%rax
cmp    -0x400(%rbp),%rax
jle    1222 <problem_008+0xf2>
mov    -0x408(%rbp),%rax
mov    %rax,-0x400(%rbp)
jmp    1227 <problem_008+0xf7>
mov    -0x40c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40c(%rbp)
jmp    1172 <problem_008+0x42>
mov    -0x400(%rbp),%rsi
lea    0x11a0(%rip),%rdi
call   1030 <printf@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x37,%bpl
mov    $0xc,%ebx
xor    %eax,%eax
lea    0xec4(%rip),%r13
nopl   0x0(%rax)
mov    %rax,(%rsp)
movsbl %bpl,%edi
call   1040 <digittoint@plt>
mov    %rax,%r15
movzbl -0xb(%rbx,%r13,1),%ebp
movsbl %bpl,%edi
call   1040 <digittoint@plt>
mov    %rax,%r14
movsbl -0xa(%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
mov    %rax,%r12
imul   %r15,%r12
movsbl -0x9(%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
mov    %rax,%r15
imul   %r14,%r15
movsbl -0x8(%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
mov    %rax,%r14
imul   %r12,%r14
movsbl -0x7(%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
mov    %rax,%r12
imul   %r15,%r12
movsbl -0x6(%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
mov    %rax,%r15
imul   %r14,%r15
movsbl -0x5(%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
mov    %rax,%r14
imul   %r12,%r14
movsbl -0x4(%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
mov    %rax,%r12
imul   %r15,%r12
movsbl -0x3(%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
mov    %rax,%r15
imul   %r14,%r15
movsbl -0x2(%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
mov    %rax,%r14
imul   %r12,%r14
movsbl -0x1(%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
mov    %rax,%r12
imul   %r15,%r12
movsbl (%rbx,%r13,1),%edi
call   1040 <digittoint@plt>
imul   %r14,%rax
imul   %r12,%rax
mov    (%rsp),%rcx
cmp    %rcx,%rax
cmovle %rcx,%rax
add    $0x1,%rbx
cmp    $0x3e7,%rbx
jne    1140 <problem_008+0x20>
lea    0x119e(%rip),%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.problem_008.number_string = [1001 x i8] c"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\00"
@.str = [5 x i8] c"%llu\00"
define void @problem_008() {
%1 = alloca [1001 x i8]
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = bitcast [1001 x i8]* %1 to i8*
store i32 13, i32* %2
store i64 0, i64* %3
store i32 0, i32* %5
br label %8
8: ; preds = %42, %0
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 2
%13 = sext i32 %12 to i64
%14 = sub i64 1001, %13
%15 = icmp ule i64 %10, %14
br i1 %15, label %16, label %45
16: ; preds = %8
store i64 1, i64* %4
store i32 0, i32* %6
br label %17
17: ; preds = %32, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %2
%20 = sub nsw i32 %19, 1
%21 = icmp sle i32 %18, %20
br i1 %21, label %22, label %35
22: ; preds = %17
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = add nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1001 x i8], [1001 x i8]* %1, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = call i64 @digittoint(i8 signext %28)
%30 = load i64, i64* %4
%31 = mul nsw i64 %30, %29
store i64 %31, i64* %4
br label %32
32: ; preds = %22
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %17
35: ; preds = %17
%36 = load i64, i64* %4
%37 = load i64, i64* %3
%38 = icmp sgt i64 %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = load i64, i64* %4
store i64 %40, i64* %3
br label %41
41: ; preds = %39, %35
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %8
45: ; preds = %8
%46 = load i64, i64* %3
%47 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %46)
ret void
}

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