#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 controlDigit(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ readPersnr(char *);
int main() {
  ;
  char inputStr[11];
  while (1) {
    if (inputStr[0] == 'q') {
      break;
    }
    readPersnr(inputStr);
    if (inputStr[0] == '\n') {
      printf("Enter pressed");
    }
    controlDigit(inputStr) == 1
        ? printf("The Swedish social security number is valid\n")
        : printf("The Swedish social security number is NOT valid\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movsbl -0xf(%rbp),%eax
cmp    $0x71,%eax
jne    1151 <main+0x21>
jmp    11a7 <main+0x77>
lea    -0xf(%rbp),%rdi
call   1050 <readPersnr@plt>
movsbl -0xf(%rbp),%eax
cmp    $0xa,%eax
jne    1173 <main+0x43>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
lea    -0xf(%rbp),%rdi
call   1040 <controlDigit@plt>
cmp    $0x1,%eax
jne    1196 <main+0x66>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
jmp    11a2 <main+0x72>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xd(%rsp),%rbx
lea    0xea9(%rip),%r14
lea    0xee0(%rip),%r15
lea    0xea9(%rip),%r12
jmp    118e <main+0x4e>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <controlDigit@plt>
cmp    $0x1,%eax
mov    %r12,%rdi
cmove  %r15,%rdi
call   1030 <puts@plt>
cmpb   $0x71,0xd(%rsp)
je     11a7 <main+0x67>
mov    %rbx,%rdi
call   1060 <readPersnr@plt>
cmpb   $0xa,0xd(%rsp)
jne    1170 <main+0x30>
mov    %r14,%rdi
call   1040 <printf@plt>
jmp    1170 <main+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter pressed\00"
@.str.1 = [45 x i8] c"The Swedish social security number is valid\0A\00"
@.str.2 = [49 x i8] c"The Swedish social security number is NOT valid\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %0, %26
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 113
br i1 %7, label %8, label %9
8: ; preds = %3
br label %28
9: ; preds = %3
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%11 = call i32 @readPersnr(i8* %10)
%12 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %9
%19 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%20 = call i32 @controlDigit(i8* %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %26
24: ; preds = %18
%25 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
%27 = phi i32 [ %23, %22 ], [ %25, %24 ]
br label %3
28: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Enter pressed\00"
@str = [48 x i8] c"The Swedish social security number is NOT valid\00"
@str.3 = [44 x i8] c"The Swedish social security number is valid\00"
define i32 @main() {
%1 = alloca [11 x i8]
%2 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %9
%4 = call i32 @readPersnr(i8* %2)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 10
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %3
%10 = call i32 @controlDigit(i8* %2)
%11 = icmp eq i32 %10, 1
%12 = select i1 %11, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0)
%13 = call i32 @puts(i8* dereferenceable(1) %12)
%14 = load i8, i8* %2
%15 = icmp eq i8 %14, 113
br i1 %15, label %16, label %3
16: ; preds = %9
ret i32 0
}