#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*/ assert(int);
int luhn_check_sum(char *);
int main() {
  char *test_card_numbers[] = {"601100099013942", "37828224631000",
                               "37144963539843",  "555555555555444",
                               "501971701010374", "552263411203590"};
  int check_bits[] = {4, 5, 1, 4, 2, 6};
  for (int i = 0; i < 6; i++) {
    assert(check_bits[i] == luhn_check_sum(test_card_numbers[i]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
lea    0xeaa(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeaf(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xeb7(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xebc(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xec1(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xec5(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xec2(%rip),%rax
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x6,-0x64(%rbp)
jge    11fe <main+0xce>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%eax
mov    %eax,-0x68(%rbp)
movslq -0x64(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1040 <luhn_check_sum@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11b9 <main+0x89>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <luhn_check_sum@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xece(%rip),%rdi
call   1030 <luhn_check_sum@plt>
xor    %edi,%edi
cmp    $0x5,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xec3(%rip),%rdi
call   1030 <luhn_check_sum@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xeb8(%rip),%rdi
call   1030 <luhn_check_sum@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xeae(%rip),%rdi
call   1030 <luhn_check_sum@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xea4(%rip),%rdi
call   1030 <luhn_check_sum@plt>
xor    %edi,%edi
cmp    $0x6,%eax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"601100099013942\00"
@.str.1 = [15 x i8] c"37828224631000\00"
@.str.2 = [15 x i8] c"37144963539843\00"
@.str.3 = [16 x i8] c"555555555555444\00"
@.str.4 = [16 x i8] c"501971701010374\00"
@.str.5 = [16 x i8] c"552263411203590\00"
@__const.main.check_bits = [6 x i32] [i32 4, i32 5, i32 1, i32 4, i32 2, i32 6]
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8*]
%3 = alloca [6 x i32]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [6 x i8*]* %2 to i8*
%6 = bitcast i8* %5 to [6 x i8*]*
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 0
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i32 0, i32 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 2
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 3
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 4
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i32 0, i32 5
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i32 0, i32 0), i8** %12
%13 = bitcast [6 x i32]* %3 to i8*
store i32 0, i32* %4
br label %14
14: ; preds = %30, %0
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 6
br i1 %16, label %17, label %33
17: ; preds = %14
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @luhn_check_sum(i8* %25)
%27 = icmp eq i32 %21, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
br label %30
30: ; preds = %17
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %14
33: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"601100099013942\00"
@.str.1 = [15 x i8] c"37828224631000\00"
@.str.2 = [15 x i8] c"37144963539843\00"
@.str.3 = [16 x i8] c"555555555555444\00"
@.str.4 = [16 x i8] c"501971701010374\00"
@.str.5 = [16 x i8] c"552263411203590\00"
define i32 @main() {
%1 = tail call i32 @luhn_check_sum(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 4
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @luhn_check_sum(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 5
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @luhn_check_sum(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @luhn_check_sum(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, 4
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i32 @luhn_check_sum(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32 %17, 2
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @luhn_check_sum(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i32 %21, 6
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
ret i32 0
}