#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*/ flushinp();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, char *, int *);
int main() {
  char msg[12 + 1];
  while (true) {
    int len;
    printf("Please input a string with no more than "
           "12"
           " characters: ");
    if (scanf("%"
              "12"
              "[^\n]%n",
              msg, &len) == 1)
      printf("Nice work! And your input is: <%s>(%d characters)\n", msg, len);
    flushinp();
    printf("Please input a hexadecimal number with no more than 10 chars: ");
    if (scanf("%10[A-Fa-f0-9]%n", msg, &len) == 1)
      printf("Nice work! And your input is: <%s>(%d characters)\n", msg, len);
    else
      printf("Are you kidding???\n");
    flushinp();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x11(%rbp),%rsi
lea    0xee0(%rip),%rdi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    117f <main+0x4f>
lea    -0x11(%rbp),%rsi
mov    -0x18(%rbp),%edx
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <flushinp@plt>
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x11(%rbp),%rsi
lea    0xf15(%rip),%rdi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11cb <main+0x9b>
lea    -0x11(%rbp),%rsi
mov    -0x18(%rbp),%edx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <main+0xa9>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <flushinp@plt>
jmp    113f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xee3(%rip),%r15
lea    0xb(%rsp),%rbx
lea    0x4(%rsp),%r12
lea    0xedc(%rip),%r13
lea    0xf08(%rip),%rbp
lea    0xf40(%rip),%r14
jmp    1193 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
lea    0xf3e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <flushinp@plt>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11c5 <main+0x85>
mov    0x4(%rsp),%edx
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <flushinp@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1180 <main+0x40>
mov    0x4(%rsp),%edx
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118c <main+0x4c>

LLVM IR (-O0):
@.str = [56 x i8] c"Please input a string with no more than 12 characters: \00"
@.str.1 = [10 x i8] c"%12[^\0A]%n\00"
@.str.2 = [51 x i8] c"Nice work! And your input is: <%s>(%d characters)\0A\00"
@.str.3 = [63 x i8] c"Please input a hexadecimal number with no more than 10 chars: \00"
@.str.4 = [17 x i8] c"%10[A-Fa-f0-9]%n\00"
@.str.5 = [20 x i8] c"Are you kidding???\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [13 x i8]
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %0, %25
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %6, i32* %3)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %10, i32 %11)
br label %13
13: ; preds = %9, %4
%14 = call i32 (...) @flushinp()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0))
%16 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%17 = call i32 @scanf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %16, i32* %3)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %20, i32 %21)
br label %25
23: ; preds = %13
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = call i32 (...) @flushinp()
br label %4
}

LLVM IR (-O2):
@.str = [56 x i8] c"Please input a string with no more than 12 characters: \00"
@.str.1 = [10 x i8] c"%12[^\0A]%n\00"
@.str.2 = [51 x i8] c"Nice work! And your input is: <%s>(%d characters)\0A\00"
@.str.3 = [63 x i8] c"Please input a hexadecimal number with no more than 10 chars: \00"
@.str.4 = [17 x i8] c"%10[A-Fa-f0-9]%n\00"
@str = [19 x i8] c"Are you kidding???\00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %22, %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32* %2)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %3, i32 %10)
br label %12
12: ; preds = %9, %5
%13 = call i32 (...) @flushinp()
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %3, i32* %2)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %3, i32 %18)
br label %22
20: ; preds = %12
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = call i32 (...) @flushinp()
br label %5
}