#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 */
#define EAGAIN 132
#define EDEADLK 131
#define EINVAL 130
#define EPERM 129
#define ESRCH 128
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ pthread_self();
int /*<<< orphan*/ show_time();
void check_errno(int err) {
  do {
    show_time();
    printf(" -- [%lu]", (unsigned long int)pthread_self());
    printf("errno = [%d]", err);
    printf("\n");
  } while (0);
  switch (err) {
  case EDEADLK:
    do {
      show_time();
      printf(" -- [%lu]", (unsigned long int)pthread_self());
      printf("EDEADLK");
      printf("\n");
    } while (0);
    break;
  case EINVAL:
    do {
      show_time();
      printf(" -- [%lu]", (unsigned long int)pthread_self());
      printf("EINVAL");
      printf("\n");
    } while (0);
    break;
  case ESRCH:
    do {
      show_time();
      printf(" -- [%lu]", (unsigned long int)pthread_self());
      printf("ESRCH");
      printf("\n");
    } while (0);
    break;
  case EAGAIN:
    do {
      show_time();
      printf(" -- [%lu]", (unsigned long int)pthread_self());
      printf("EAGAIN");
      printf("\n");
    } while (0);
    break;
  case EPERM:
    do {
      show_time();
      printf(" -- [%lu]", (unsigned long int)pthread_self());
      printf("EPERM");
      printf("\n");
    } while (0);
    break;
  default:
    do {
      show_time();
      printf(" -- [%lu]", (unsigned long int)pthread_self());
      printf("no such errno");
      printf("\n");
    } while (0);
  }
}


x86 assembly (clang, -O0):
<check_errno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <show_time@plt>
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %rax,%rsi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     12fb <check_errno+0x1cb>
mov    -0x10(%rbp),%rax
lea    0xe67(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    11a7 <check_errno+0x77>
mov    $0x0,%al
call   1040 <show_time@plt>
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %rax,%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1340 <check_errno+0x210>
jmp    11ec <check_errno+0xbc>
mov    $0x0,%al
call   1040 <show_time@plt>
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %rax,%rsi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1340 <check_errno+0x210>
jmp    1231 <check_errno+0x101>
mov    $0x0,%al
call   1040 <show_time@plt>
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %rax,%rsi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1340 <check_errno+0x210>
jmp    1276 <check_errno+0x146>
mov    $0x0,%al
call   1040 <show_time@plt>
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %rax,%rsi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1340 <check_errno+0x210>
jmp    12bb <check_errno+0x18b>
mov    $0x0,%al
call   1040 <show_time@plt>
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %rax,%rsi
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1340 <check_errno+0x210>
jmp    1300 <check_errno+0x1d0>
mov    $0x0,%al
call   1040 <show_time@plt>
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %rax,%rsi
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1340 <check_errno+0x210>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_errno>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <show_time@plt>
xor    %eax,%eax
call   1060 <pthread_self@plt>
lea    0xea8(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffff80,%ebx
cmp    $0x4,%ebx
ja     1197 <check_errno+0x57>
movslq %ebx,%rax
lea    0xeba(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    119e <check_errno+0x5e>
lea    0xe9b(%rip),%rbx
xor    %eax,%eax
call   1050 <show_time@plt>
xor    %eax,%eax
call   1060 <pthread_self@plt>
lea    0xe4d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [10 x i8] c" -- [%lu]\00"
@.str.1 = [13 x i8] c"errno = [%d]\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [8 x i8] c"EDEADLK\00"
@.str.4 = [7 x i8] c"EINVAL\00"
@.str.5 = [6 x i8] c"ESRCH\00"
@.str.6 = [7 x i8] c"EAGAIN\00"
@.str.7 = [6 x i8] c"EPERM\00"
@.str.8 = [14 x i8] c"no such errno\00"
define void @check_errno(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
br label %3
3: ; preds = %1
%4 = call i32 (...) @show_time()
%5 = call i64 (...) @pthread_self()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %5)
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %3
%11 = load i32, i32* %2
switch i32 %11, label %52 [
i32 131, label %12
i32 130, label %20
i32 128, label %28
i32 132, label %36
i32 129, label %44
]
12: ; preds = %10
br label %13
13: ; preds = %12
%14 = call i32 (...) @show_time()
%15 = call i64 (...) @pthread_self()
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %13
br label %60
20: ; preds = %10
br label %21
21: ; preds = %20
%22 = call i32 (...) @show_time()
%23 = call i64 (...) @pthread_self()
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %21
br label %60
28: ; preds = %10
br label %29
29: ; preds = %28
%30 = call i32 (...) @show_time()
%31 = call i64 (...) @pthread_self()
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %29
br label %60
36: ; preds = %10
br label %37
37: ; preds = %36
%38 = call i32 (...) @show_time()
%39 = call i64 (...) @pthread_self()
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %37
br label %60
44: ; preds = %10
br label %45
45: ; preds = %44
%46 = call i32 (...) @show_time()
%47 = call i64 (...) @pthread_self()
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %45
br label %60
52: ; preds = %10
br label %53
53: ; preds = %52
%54 = call i32 (...) @show_time()
%55 = call i64 (...) @pthread_self()
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %53
br label %60
60: ; preds = %59, %51, %43, %35, %27, %19
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c" -- [%lu]\00"
@.str.1 = [13 x i8] c"errno = [%d]\00"
@.str.3 = [8 x i8] c"EDEADLK\00"
@.str.4 = [7 x i8] c"EINVAL\00"
@.str.5 = [6 x i8] c"ESRCH\00"
@.str.6 = [7 x i8] c"EAGAIN\00"
@.str.7 = [6 x i8] c"EPERM\00"
@.str.8 = [14 x i8] c"no such errno\00"
@reltable.check_errno = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.5 to i64), i64 ptrtoint ([5 x i32]* @reltable.check_errno to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.7 to i64), i64 ptrtoint ([5 x i32]* @reltable.check_errno to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([5 x i32]* @reltable.check_errno to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([5 x i32]* @reltable.check_errno to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([5 x i32]* @reltable.check_errno to i64)) to i32)]
define void @check_errno(i32 %0) {
%2 = tail call i32 (...) @show_time()
%3 = tail call i64 (...) @pthread_self()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%6 = tail call i32 @putchar(i32 10)
%7 = add i32 %0, -128
%8 = icmp ult i32 %7, 5
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = sext i32 %7 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.check_errno to i8*), i64 %11)
br label %13
13: ; preds = %1, %9
%14 = phi i8* [ %12, %9 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), %1 ]
%15 = tail call i32 (...) @show_time()
%16 = tail call i64 (...) @pthread_self()
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %14)
%19 = tail call i32 @putchar(i32 10)
ret void
}