#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 /*<<< orphan*/ printf(char *, int);
int main() {
  char b[] =
      "731671765313306249192251196744265747423553491949349698352031277450632623"
      "957831801698480186947885184385861560789112949495459501737958331952853208"
      "805511125406987471585238630507156932909632952274430435576689664895044524"
      "452316173185640309871112172238311362229893423380308135336276614282806444"
      "486645238749303589072962904915604407723907138105158593079608667017242712"
      "188399879790879227492190169972088809377665727333001053367881220235421809"
      "751254540594752243525849077116705560136048395864467063244157221553975369"
      "781797784617406495514929086256932197846862248283972241375657056057490261"
      "407972968652414535100474821663704844031998900088952434506585412275886668"
      "811642717147992444292823086346567481391912316282458617866458359124566529"
      "476545682848912883142607690042242190226710556263211111093705442175069416"
      "589604080719840385096245544436298123098787992724428490918884580156166097"
      "919133875499200524063689912560717606058861164671094050775410022569831552"
      "0005593572972571636269561882670428252483600823257530420752963450";
  int max_product = 0;
  int product;
  for (int i = 2; i <= 997; i++) {
    product = (b[i - 2] - '0') * (b[i - 1] - '0') * (b[i] - '0') *
              (b[i + 1] - '0') * (b[i + 2] - '0');
    if (product > max_product) {
      max_product = product;
    }
  }
  printf("%d\n", max_product);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
lea    0xec0(%rip),%rsi
mov    $0x3e9,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x3f4(%rbp)
movl   $0x2,-0x3fc(%rbp)
cmpl   $0x3e5,-0x3fc(%rbp)
jg     1224 <main+0x104>
mov    -0x3fc(%rbp),%eax
sub    $0x2,%eax
cltq
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
sub    $0x30,%eax
mov    -0x3fc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x3f0(%rbp,%rcx,1),%ecx
ff
sub    $0x30,%ecx
imul   %ecx,%eax
movslq -0x3fc(%rbp),%rcx
movsbl -0x3f0(%rbp,%rcx,1),%ecx
ff
sub    $0x30,%ecx
imul   %ecx,%eax
mov    -0x3fc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x3f0(%rbp,%rcx,1),%ecx
ff
sub    $0x30,%ecx
imul   %ecx,%eax
mov    -0x3fc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsbl -0x3f0(%rbp,%rcx,1),%ecx
ff
sub    $0x30,%ecx
imul   %ecx,%eax
mov    %eax,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%eax
cmp    -0x3f4(%rbp),%eax
jle    120b <main+0xeb>
mov    -0x3f8(%rbp),%eax
mov    %eax,-0x3f4(%rbp)
jmp    1210 <main+0xf0>
mov    -0x3fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3fc(%rbp)
jmp    115e <main+0x3e>
mov    -0x3f4(%rbp),%esi
lea    0x11b8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %esi,%esi
mov    $0x37,%r10b
mov    $0x33,%al
mov    $0x31,%r11b
mov    $0x36,%dil
mov    $0x4,%ecx
lea    0xed6(%rip),%r8
nopw   0x0(%rax,%rax,1)
mov    %esi,%r9d
movsbl %r10b,%esi
mov    %eax,%r10d
movsbl %al,%edx
mov    %r11d,%eax
mov    %edi,%r11d
add    $0xffffffd0,%esi
add    $0xffffffd0,%edx
imul   %esi,%edx
movsbl %al,%esi
add    $0xffffffd0,%esi
movsbl %dil,%ebx
add    $0xffffffd0,%ebx
imul   %esi,%ebx
imul   %edx,%ebx
movsbl (%rcx,%r8,1),%edi
mov    %edi,%esi
add    $0xffffffd0,%esi
imul   %ebx,%esi
cmp    %r9d,%esi
cmovle %r9d,%esi
add    $0x1,%rcx
cmp    $0x3e8,%rcx
jne    1130 <main+0x20>
lea    0x1262(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.main.b = [1001 x i8] c"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\00"
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
br label %3
1: ; preds = %3
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
ret i32 0
3: ; preds = %0, %3
%4 = phi i8 [ 54, %0 ], [ %24, %3 ]
%5 = phi i8 [ 49, %0 ], [ %4, %3 ]
%6 = phi i8 [ 51, %0 ], [ %5, %3 ]
%7 = phi i8 [ 55, %0 ], [ %6, %3 ]
%8 = phi i64 [ 2, %0 ], [ %18, %3 ]
%9 = phi i32 [ 0, %0 ], [ %29, %3 ]
%10 = sext i8 %7 to i32
%11 = add nsw i32 %10, -48
%12 = sext i8 %6 to i32
%13 = add nsw i32 %12, -48
%14 = mul nsw i32 %13, %11
%15 = sext i8 %5 to i32
%16 = add nsw i32 %15, -48
%17 = mul nsw i32 %14, %16
%18 = add nuw nsw i64 %8, 1
%19 = sext i8 %4 to i32
%20 = add nsw i32 %19, -48
%21 = mul nsw i32 %17, %20
%22 = add nuw nsw i64 %8, 2
%23 = getelementptr inbounds [1001 x i8], [1001 x i8]* @__const.main.b, 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 %21, %26
%28 = icmp sgt i32 %27, %9
%29 = select i1 %28, i32 %27, i32 %9
%30 = icmp eq i64 %18, 998
br i1 %30, label %1, label %3
}