int error_simgen_geterrorcodes(void *gen, unsigned int *errorcodes,
                               int num_codes, int *mil) {
  int ret_codes = 3;
  switch (num_codes) {
  default:
    if (num_codes >= 3) {
      errorcodes[4] = 0x41;
      errorcodes[5] = 0x23;
    }
  case 2:
    if (num_codes >= 2) {
      errorcodes[2] = 0x80;
      errorcodes[3] = 0x03;
    }
  case 1:
    if (num_codes >= 1) {
      errorcodes[0] = 0x01;
      errorcodes[1] = 0x04;
    }
  }
  *mil = 1;
  return ret_codes;
}


x86 assembly (clang, -O0):
<error_simgen_geterrorcodes>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x3,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x1,%eax
je     1189 <error_simgen_geterrorcodes+0x89>
jmp    112e <error_simgen_geterrorcodes+0x2e>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     1164 <error_simgen_geterrorcodes+0x64>
jmp    113f <error_simgen_geterrorcodes+0x3f>
cmpl   $0x3,-0x14(%rbp)
jl     115f <error_simgen_geterrorcodes+0x5f>
mov    -0x10(%rbp),%rax
movl   $0x41,0x10(%rax)
mov    -0x10(%rbp),%rax
movl   $0x23,0x14(%rax)
jmp    1164 <error_simgen_geterrorcodes+0x64>
cmpl   $0x2,-0x14(%rbp)
jl     1184 <error_simgen_geterrorcodes+0x84>
mov    -0x10(%rbp),%rax
movl   $0x80,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,0xc(%rax)
jmp    1189 <error_simgen_geterrorcodes+0x89>
cmpl   $0x1,-0x14(%rbp)
jl     11a8 <error_simgen_geterrorcodes+0xa8>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x4,0x4(%rax)
jmp    11ad <error_simgen_geterrorcodes+0xad>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x24(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<error_simgen_geterrorcodes>:
cmp    $0x1,%edx
je     1128 <error_simgen_geterrorcodes+0x28>
cmp    $0x2,%edx
je     111a <error_simgen_geterrorcodes+0x1a>
jle    1135 <error_simgen_geterrorcodes+0x35>
movabs $0x2300000041,%rax
mov    %rax,0x10(%rsi)
movabs $0x300000080,%rax
mov    %rax,0x8(%rsi)
movabs $0x400000001,%rax
mov    %rax,(%rsi)
movl   $0x1,(%rcx)
mov    $0x3,%eax
ret

LLVM IR (-O0):
define i32 @error_simgen_geterrorcodes(i8* %0, i32* %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store i32 3, i32* %9
%10 = load i32, i32* %7
switch i32 %10, label %11 [
i32 2, label %20
i32 1, label %29
]
11: ; preds = %4
%12 = load i32, i32* %7
%13 = icmp sge i32 %12, 3
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32*, i32** %6
%16 = getelementptr inbounds i32, i32* %15, i64 4
store i32 65, i32* %16
%17 = load i32*, i32** %6
%18 = getelementptr inbounds i32, i32* %17, i64 5
store i32 35, i32* %18
br label %19
19: ; preds = %14, %11
br label %20
20: ; preds = %4, %19
%21 = load i32, i32* %7
%22 = icmp sge i32 %21, 2
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i32*, i32** %6
%25 = getelementptr inbounds i32, i32* %24, i64 2
store i32 128, i32* %25
%26 = load i32*, i32** %6
%27 = getelementptr inbounds i32, i32* %26, i64 3
store i32 3, i32* %27
br label %28
28: ; preds = %23, %20
br label %29
29: ; preds = %4, %28
%30 = load i32, i32* %7
%31 = icmp sge i32 %30, 1
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i32*, i32** %6
%34 = getelementptr inbounds i32, i32* %33, i64 0
store i32 1, i32* %34
%35 = load i32*, i32** %6
%36 = getelementptr inbounds i32, i32* %35, i64 1
store i32 4, i32* %36
br label %37
37: ; preds = %32, %29
br label %38
38: ; preds = %37
%39 = load i32*, i32** %8
store i32 1, i32* %39
%40 = load i32, i32* %9
ret i32 %40
}

LLVM IR (-O2):
define i32 @error_simgen_geterrorcodes(i8* nocapture readnone %0, i32* nocapture writeonly %1, i32 %2, i32* nocapture writeonly %3) {
switch i32 %2, label %5 [
i32 2, label %10
i32 1, label %13
]
5: ; preds = %4
%6 = icmp sgt i32 %2, 2
br i1 %6, label %7, label %15
7: ; preds = %5
%8 = getelementptr inbounds i32, i32* %1, i64 4
store i32 65, i32* %8
%9 = getelementptr inbounds i32, i32* %1, i64 5
store i32 35, i32* %9
br label %10
10: ; preds = %7, %4
%11 = getelementptr inbounds i32, i32* %1, i64 2
store i32 128, i32* %11
%12 = getelementptr inbounds i32, i32* %1, i64 3
store i32 3, i32* %12
br label %13
13: ; preds = %10, %4
store i32 1, i32* %1
%14 = getelementptr inbounds i32, i32* %1, i64 1
store i32 4, i32* %14
br label %15
15: ; preds = %5, %13
store i32 1, i32* %3
ret i32 3
}