#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 strlen(char const *);
int euler_problem_8() {
  const char *str =
      "731671765313306249192251196744265747423553491949349698352031277450632623"
      "957831801698480186947885184385861560789112949495459501737958331952853208"
      "805511125406987471585238630507156932909632952274430435576689664895044524"
      "452316173185640309871112172238311362229893423380308135336276614282806444"
      "486645238749303589072962904915604407723907138105158593079608667017242712"
      "188399879790879227492190169972088809377665727333001053367881220235421809"
      "751254540594752243525849077116705560136048395864467063244157221553975369"
      "781797784617406495514929086256932197846862248283972241375657056057490261"
      "407972968652414535100474821663704844031998900088952434506585412275886668"
      "811642717147992444292823086346567481391912316282458617866458359124566529"
      "476545682848912883142607690042242190226710556263211111093705442175069416"
      "589604080719840385096245544436298123098787992724428490918884580156166097"
      "919133875499200524063689912560717606058861164671094050775410022569831552"
      "0005593572972571636269561882670428252483600823257530420752963450";
  int i, a, b, c, d, e, p, limit = strlen(str) - 4, max = 0;
  for (i = 0; i < limit; ++i) {
    a = str[i] - '0';
    b = str[i + 1] - '0';
    c = str[i + 2] - '0';
    d = str[i + 3] - '0';
    e = str[i + 4] - '0';
    p = a * b * c * d * e;
    if (p > max) {
      max = p;
    }
  }
  return max;
}


x86 assembly (clang, -O0):
<euler_problem_8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xee1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x4,%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11f5 <euler_problem_8+0xe5>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    11e2 <euler_problem_8+0xd2>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    11e7 <euler_problem_8+0xd7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <euler_problem_8+0x30>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<euler_problem_8>:
push   %r14
push   %rbx
push   %rax
lea    0xee5(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
xor    %r11d,%r11d
cmp    $0x5,%eax
jl     118b <euler_problem_8+0x7b>
add    $0xfffffffc,%eax
xor    %edx,%edx
mov    $0x37,%r9b
mov    $0x33,%cl
mov    $0x31,%r8b
mov    $0x36,%r10b
xor    %r11d,%r11d
xchg   %ax,%ax
movsbl %r9b,%edi
mov    %ecx,%r9d
movsbl %cl,%ebx
mov    %r8d,%ecx
mov    %r10d,%r8d
add    $0xffffffd0,%edi
add    $0xffffffd0,%ebx
imul   %edi,%ebx
movsbl %cl,%edi
add    $0xffffffd0,%edi
movsbl %r10b,%esi
add    $0xffffffd0,%esi
imul   %edi,%esi
imul   %ebx,%esi
movsbl 0x4(%rdx,%r14,1),%r10d
add    $0x1,%rdx
mov    %r10d,%edi
add    $0xffffffd0,%edi
imul   %esi,%edi
cmp    %r11d,%edi
cmovg  %edi,%r11d
cmp    %rdx,%rax
jne    1140 <euler_problem_8+0x30>
mov    %r11d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [1001 x i8] c"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\00"
define i32 @euler_problem_8() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([1001 x i8], [1001 x i8]* @.str, i64 0, i64 0))
%2 = icmp sgt i32 %1, 4
br i1 %2, label %3, label %34
3: ; preds = %0
%4 = add nsw i32 %1, -4
%5 = zext i32 %4 to i64
br label %6
6: ; preds = %3, %6
%7 = phi i8 [ 54, %3 ], [ %24, %6 ]
%8 = phi i8 [ 49, %3 ], [ %7, %6 ]
%9 = phi i8 [ 51, %3 ], [ %8, %6 ]
%10 = phi i8 [ 55, %3 ], [ %9, %6 ]
%11 = phi i64 [ 0, %3 ], [ %15, %6 ]
%12 = phi i32 [ 0, %3 ], [ %32, %6 ]
%13 = sext i8 %10 to i32
%14 = add nsw i32 %13, -48
%15 = add nuw nsw i64 %11, 1
%16 = sext i8 %9 to i32
%17 = add nsw i32 %16, -48
%18 = sext i8 %8 to i32
%19 = add nsw i32 %18, -48
%20 = sext i8 %7 to i32
%21 = add nsw i32 %20, -48
%22 = add nuw nsw i64 %11, 4
%23 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = add nsw i32 %25, -48
%27 = mul nsw i32 %17, %14
%28 = mul nsw i32 %27, %19
%29 = mul nsw i32 %28, %21
%30 = mul nsw i32 %29, %26
%31 = icmp sgt i32 %30, %12
%32 = select i1 %31, i32 %30, i32 %12
%33 = icmp eq i64 %15, %5
br i1 %33, label %34, label %6
34: ; preds = %6, %0
%35 = phi i32 [ 0, %0 ], [ %32, %6 ]
ret i32 %35
}