#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 */
long get_greatest_product(char *, int, int);
int /*<<< orphan*/ printf(char *, int, char *, long);
int problem8(void) {
  char number[1001] =
      "731671765313306249192251196744265747423553491949349698352031277450632623"
      "957831801698480186947885184385861560789112949495459501737958331952853208"
      "805511125406987471585238630507156932909632952274430435576689664895044524"
      "452316173185640309871112172238311362229893423380308135336276614282806444"
      "486645238749303589072962904915604407723907138105158593079608667017242712"
      "188399879790879227492190169972088809377665727333001053367881220235421809"
      "751254540594752243525849077116705560136048395864467063244157221553975369"
      "781797784617406495514929086256932197846862248283972241375657056057490261"
      "407972968652414535100474821663704844031998900088952434506585412275886668"
      "811642717147992444292823086346567481391912316282458617866458359124566529"
      "476545682848912883142607690042242190226710556263211111093705442175069416"
      "589604080719840385096245544436298123098787992724428490918884580156166097"
      "919133875499200524063689912560717606058861164671094050775410022569831552"
      "0005593572972571636269561882670428252483600823257530420752963450";
  long num = get_greatest_product(number, 1000, 13);
  printf(
      "The greatest product of %d adjacent digits in the number\n%s\nis %ld\n",
      13, number, num);
  return 0;
}


x86 assembly (clang, -O0):
<problem8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
lea    -0x3f0(%rbp),%rdi
lea    0xeb7(%rip),%rsi
mov    $0x3e9,%edx
call   1040 <memcpy@plt>
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
mov    $0xd,%edx
call   1050 <get_greatest_product@plt>
mov    %rax,-0x3f8(%rbp)
lea    -0x3f0(%rbp),%rdx
mov    -0x3f8(%rbp),%rcx
lea    0x1264(%rip),%rdi
mov    $0xd,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<problem8>:
push   %rbx
sub    $0x3f0,%rsp
lea    0xec1(%rip),%rsi
mov    %rsp,%rbx
mov    $0x3e9,%edx
mov    %rbx,%rdi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    $0xd,%edx
call   1050 <get_greatest_product@plt>
lea    0x1281(%rip),%rdi
mov    $0xd,%esi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.problem8.number = [1001 x i8] c"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\00"
@.str = [68 x i8] c"The greatest product of %d adjacent digits in the number\0A%s\0Ais %ld\0A\00"
define i32 @problem8() {
%1 = alloca [1001 x i8]
%2 = alloca i64
%3 = bitcast [1001 x i8]* %1 to i8*
%4 = getelementptr inbounds [1001 x i8], [1001 x i8]* %1, i64 0, i64 0
%5 = call i64 @get_greatest_product(i8* %4, i32 1000, i32 13)
store i64 %5, i64* %2
%6 = getelementptr inbounds [1001 x i8], [1001 x i8]* %1, i64 0, i64 0
%7 = load i64, i64* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i32 13, i8* %6, i64 %7)
ret i32 0
}

LLVM IR (-O2):
@__const.problem8.number = [1001 x i8] c"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\00"
@.str = [68 x i8] c"The greatest product of %d adjacent digits in the number\0A%s\0Ais %ld\0A\00"
define i32 @problem8() {
%1 = alloca [1001 x i8]
%2 = getelementptr inbounds [1001 x i8], [1001 x i8]* %1, i64 0, i64 0
%3 = call i64 @get_greatest_product(i8* %2, i32 1000, i32 13)
%4 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i32 13, i8* %2, i64 %3)
ret i32 0
}