#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 */
char EOF;
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdin;
void readPersnr(char *person) {
  char c;
  int a;
  char string[11];
  puts("Enter a Swedish social security number (10 digits):");
  fgets(person, 11, stdin);
  while ((c = getchar() != '\n') && (a = getchar() != EOF)) {
    ;
  }
  puts(person);
}


x86 assembly (clang, -O0):
<readPersnr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e95(%rip),%rax
mov    (%rax),%edx
mov    $0xb,%esi
call   1040 <fgets@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x9(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1c(%rbp)
je     11af <readPersnr+0x7f>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
mov    0x2e47(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x10(%rbp)
mov    %al,-0x1c(%rbp)
mov    -0x1c(%rbp),%al
test   $0x1,%al
jne    11bf <readPersnr+0x8f>
jmp    11c4 <readPersnr+0x94>
jmp    115f <readPersnr+0x2f>
mov    -0x8(%rbp),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readPersnr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0xb,%esi
call   1040 <fgets@plt>
mov    0x2e80(%rip),%rbx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1176 <readPersnr+0x46>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%rbx),%al
jne    1160 <readPersnr+0x30>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"Enter a Swedish social security number (10 digits):\00"
@stdin = global i32 0
@EOF = global i8 0
define void @readPersnr(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
%5 = alloca [11 x i8]
store i8* %0, i8** %2
%6 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %2
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 11, i32 %8)
br label %10
10: ; preds = %27, %1
%11 = call signext i8 (...) @getchar()
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
%14 = zext i1 %13 to i32
%15 = trunc i32 %14 to i8
store i8 %15, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %10
%19 = call signext i8 (...) @getchar()
%20 = sext i8 %19 to i32
%21 = load i8, i8* @EOF
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %20, %22
%24 = zext i1 %23 to i32
store i32 %24, i32* %4
br label %25
25: ; preds = %18, %10
%26 = phi i1 [ false, %10 ], [ %23, %18 ]
br i1 %26, label %27, label %28
27: ; preds = %25
br label %10
28: ; preds = %25
%29 = load i8*, i8** %2
%30 = call i32 @puts(i8* %29)
ret void
}

LLVM IR (-O2):
@.str = [52 x i8] c"Enter a Swedish social security number (10 digits):\00"
@stdin = global i32 0
@EOF = global i8 0
define void @readPersnr(i8* %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = tail call i32 @fgets(i8* %0, i32 11, i32 %3)
br label %5
5: ; preds = %8, %1
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call signext i8 (...) @getchar()
%10 = load i8, i8* @EOF
%11 = icmp eq i8 %9, %10
br i1 %11, label %12, label %5
12: ; preds = %5, %8
%13 = tail call i32 @puts(i8* dereferenceable(1) %0)
ret void
}