#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 /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int d, i1, i2, i3, i4, i5, j1, j2, j3, j4, j5, first_sum, second_sum,
      check_digit;
  printf("Enter the first (single) digit: ");
  scanf("%1d", &d);
  printf("Enter first group of five digits: ");
  scanf("%1d%1d%1d%1d%1d", &i1, &i2, &i3, &i4, &i5);
  printf("Enter the second group of five digits: ");
  scanf("%1d%1d%1d%1d%1d", &j1, &j2, &j3, &j4, &j5);
  first_sum = d + i2 + i4 + j1 + j3 + j5;
  second_sum = i1 + i3 + i5 + j2 + j4;
  check_digit = 9 - (first_sum * 3 + second_sum - 1) % 10;
  printf("Check digit: %1d\n", check_digit);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0c(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
lea    -0x1c(%rbp),%r9
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    -0x30(%rbp),%r9
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
add    -0x18(%rbp),%eax
add    -0x20(%rbp),%eax
add    -0x28(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
add    -0x24(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
imul   $0x3,-0x34(%rbp),%eax
add    -0x38(%rbp),%eax
sub    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x9,%eax
sub    %edx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf16(%rip),%rdi
lea    0x2c(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee9(%rip),%rbx
lea    0x28(%rsp),%rsi
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0x4(%rsp),%r9
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x24(%rsp),%eax
add    0x2c(%rsp),%eax
add    0x1c(%rsp),%eax
add    0x14(%rsp),%eax
add    0xc(%rsp),%eax
add    0x4(%rsp),%eax
mov    0x28(%rsp),%ecx
mov    0x8(%rsp),%edx
add    0x20(%rsp),%ecx
lea    (%rax,%rax,2),%eax
add    %eax,%ecx
add    0x18(%rsp),%ecx
add    0x10(%rsp),%ecx
lea    (%rdx,%rcx,1),%eax
add    $0xffffffff,%eax
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%esi
sub    %eax,%esi
add    $0x9,%esi
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter the first (single) digit: \00"
@.str.1 = [4 x i8] c"%1d\00"
@.str.2 = [35 x i8] c"Enter first group of five digits: \00"
@.str.3 = [16 x i8] c"%1d%1d%1d%1d%1d\00"
@.str.4 = [40 x i8] c"Enter the second group of five digits: \00"
@.str.5 = [18 x i8] c"Check digit: %1d\0A\00"
define i32 @main() {
%1 = alloca i32
%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
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6, i32* %7)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32* %8, i32* %9, i32* %10, i32* %11, i32* %12)
%22 = load i32, i32* %2
%23 = load i32, i32* %4
%24 = add nsw i32 %22, %23
%25 = load i32, i32* %6
%26 = add nsw i32 %24, %25
%27 = load i32, i32* %8
%28 = add nsw i32 %26, %27
%29 = load i32, i32* %10
%30 = add nsw i32 %28, %29
%31 = load i32, i32* %12
%32 = add nsw i32 %30, %31
store i32 %32, i32* %13
%33 = load i32, i32* %3
%34 = load i32, i32* %5
%35 = add nsw i32 %33, %34
%36 = load i32, i32* %7
%37 = add nsw i32 %35, %36
%38 = load i32, i32* %9
%39 = add nsw i32 %37, %38
%40 = load i32, i32* %11
%41 = add nsw i32 %39, %40
store i32 %41, i32* %14
%42 = load i32, i32* %13
%43 = mul nsw i32 %42, 3
%44 = load i32, i32* %14
%45 = add nsw i32 %43, %44
%46 = sub nsw i32 %45, 1
%47 = srem i32 %46, 10
%48 = sub nsw i32 9, %47
store i32 %48, i32* %15
%49 = load i32, i32* %15
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Enter the first (single) digit: \00"
@.str.1 = [4 x i8] c"%1d\00"
@.str.2 = [35 x i8] c"Enter first group of five digits: \00"
@.str.3 = [16 x i8] c"%1d%1d%1d%1d%1d\00"
@.str.4 = [40 x i8] c"Enter the second group of five digits: \00"
@.str.5 = [18 x i8] c"Check digit: %1d\0A\00"
define i32 @main() {
%1 = alloca i32
%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
%11 = alloca i32
%12 = bitcast i32* %1 to i8*
%13 = bitcast i32* %2 to i8*
%14 = bitcast i32* %3 to i8*
%15 = bitcast i32* %4 to i8*
%16 = bitcast i32* %5 to i8*
%17 = bitcast i32* %6 to i8*
%18 = bitcast i32* %7 to i8*
%19 = bitcast i32* %8 to i8*
%20 = bitcast i32* %9 to i8*
%21 = bitcast i32* %10 to i8*
%22 = bitcast i32* %11 to i8*
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%24 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5, i32* %6)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32* %7, i32* %8, i32* %9, i32* %10, i32* %11)
%29 = load i32, i32* %1
%30 = load i32, i32* %3
%31 = add nsw i32 %30, %29
%32 = load i32, i32* %5
%33 = add nsw i32 %31, %32
%34 = load i32, i32* %7
%35 = add nsw i32 %33, %34
%36 = load i32, i32* %9
%37 = add nsw i32 %35, %36
%38 = load i32, i32* %11
%39 = add nsw i32 %37, %38
%40 = load i32, i32* %2
%41 = load i32, i32* %4
%42 = load i32, i32* %6
%43 = load i32, i32* %8
%44 = load i32, i32* %10
%45 = mul nsw i32 %39, 3
%46 = add i32 %40, -1
%47 = add i32 %46, %41
%48 = add i32 %47, %45
%49 = add i32 %48, %42
%50 = add i32 %49, %43
%51 = add i32 %50, %44
%52 = srem i32 %51, 10
%53 = sub nsw i32 9, %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %53)
ret i32 0
}