#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 */
scalar_t__ EINVAL;
int /*<<< orphan*/ _dosmaperr(int);
scalar_t__ errno;
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i;
  printf("/* Generated file. Do not edit. */\n");
  printf("int winerror_to_errno(int winerror)\n");
  printf("{\n\tswitch(winerror) {\n");
  for (i = 1; i < 65000; i++) {
    _dosmaperr(i);
    if (errno == EINVAL)
      continue;
    printf("\t\tcase %d: return %d;\n", i, errno);
  }
  printf("\t\tdefault: return EINVAL;\n");
  printf("\t}\n}\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0xfde8,-0x8(%rbp)
jge    11bd <main+0x9d>
mov    -0x8(%rbp),%edi
call   1040 <_dosmaperr@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%rax
mov    0x2e52(%rip),%rcx
cmp    (%rcx),%rax
jne    1194 <main+0x74>
jmp    11af <main+0x8f>
mov    -0x8(%rbp),%esi
mov    0x2e42(%rip),%rax
mov    (%rax),%rdx
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1160 <main+0x40>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    0x2e78(%rip),%r15
mov    0x2e69(%rip),%r12
lea    0xe8a(%rip),%r14
jmp    118b <main+0x5b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0xfde8,%ebx
je     11a9 <main+0x79>
mov    %ebx,%edi
call   1050 <_dosmaperr@plt>
mov    (%r15),%rdx
cmp    (%r12),%rdx
je     1180 <main+0x50>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <main+0x50>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"/* Generated file. Do not edit. */\0A\00"
@.str.1 = [37 x i8] c"int winerror_to_errno(int winerror)\0A\00"
@.str.2 = [23 x i8] c"{\0A\09switch(winerror) {\0A\00"
@errno = global i64 0
@EINVAL = global i64 0
@.str.3 = [23 x i8] c"\09\09case %d: return %d;\0A\00"
@.str.4 = [27 x i8] c"\09\09default: return EINVAL;\0A\00"
@.str.5 = [6 x i8] c"\09}\0A}\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 65000
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32, i32* %2
%11 = call i32 @_dosmaperr(i32 %10)
%12 = load i64, i64* @errno
%13 = load i64, i64* @EINVAL
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %9
br label %20
16: ; preds = %9
%17 = load i32, i32* %2
%18 = load i64, i64* @errno
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %17, i64 %18)
br label %20
20: ; preds = %16, %15
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %6
23: ; preds = %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@errno = global i64 0
@EINVAL = global i64 0
@.str.3 = [23 x i8] c"\09\09case %d: return %d;\0A\00"
@str = [35 x i8] c"/* Generated file. Do not edit. */\00"
@str.6 = [36 x i8] c"int winerror_to_errno(int winerror)\00"
@str.7 = [22 x i8] c"{\0A\09switch(winerror) {\00"
@str.8 = [26 x i8] c"\09\09default: return EINVAL;\00"
@str.9 = [5 x i8] c"\09}\0A}\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.6, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
br label %4
4: ; preds = %0, %12
%5 = phi i32 [ 1, %0 ], [ %13, %12 ]
%6 = tail call i32 @_dosmaperr(i32 %5)
%7 = load i64, i64* @errno
%8 = load i64, i64* @EINVAL
%9 = icmp eq i64 %7, %8
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %5, i64 %7)
br label %12
12: ; preds = %4, %10
%13 = add nuw nsw i32 %5, 1
%14 = icmp eq i32 %13, 65000
br i1 %14, label %15, label %4
15: ; preds = %12
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.8, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0))
ret i32 0
}