#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 */
typedef int /*<<< orphan*/ bitmap;

/* Variables and functions */
int proc_type_std(unsigned char, int, unsigned char);
int process_std(unsigned int bitmap, unsigned char hcode, unsigned char cmdcode,
                int source) {
  int unit, ret = 0;
  switch (source) {
  case 4:
    if (!bitmap) {
      ret = proc_type_std(hcode, 0, cmdcode);
    } else
      for (unit = 0; unit < 16; unit++)
        if ((bitmap) & (1 << unit)) {
          ret = proc_type_std(hcode, unit, cmdcode);
          if (ret)
            break;
        }
    break;
  }
  return ret;
}


x86 assembly (clang, -O0):
<process_std>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %edi,-0x4(%rbp)
mov    %dl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
mov    %ecx,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
jne    11d5 <process_std+0xc5>
jmp    1141 <process_std+0x31>
cmpl   $0x0,-0x4(%rbp)
jne    1164 <process_std+0x54>
mov    -0x5(%rbp),%al
xor    %esi,%esi
movzbl %al,%edi
movzbl -0x6(%rbp),%edx
call   1030 <proc_type_std@plt>
mov    %eax,-0x14(%rbp)
jmp    11d0 <process_std+0xc0>
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    11cb <process_std+0xbb>
mov    -0x4(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11b8 <process_std+0xa8>
mov    -0x5(%rbp),%al
mov    -0x10(%rbp),%esi
movzbl %al,%edi
movzbl -0x6(%rbp),%edx
call   1030 <proc_type_std@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11b3 <process_std+0xa3>
jmp    11cb <process_std+0xbb>
jmp    11b8 <process_std+0xa8>
jmp    11bd <process_std+0xad>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116b <process_std+0x5b>
jmp    11d0 <process_std+0xc0>
jmp    11d5 <process_std+0xc5>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_std>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
cmp    $0x4,%ecx
jne    116a <process_std+0x5a>
mov    %edi,%ebx
test   %edi,%edi
je     1150 <process_std+0x40>
xor    %ebp,%ebp
movzbl %sil,%r14d
movzbl %dl,%r15d
jmp    1138 <process_std+0x28>
add    $0x1,%ebp
cmp    $0x10,%ebp
je     1168 <process_std+0x58>
bt     %ebp,%ebx
jae    1130 <process_std+0x20>
mov    %r14d,%edi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <proc_type_std@plt>
test   %eax,%eax
je     1130 <process_std+0x20>
jmp    116a <process_std+0x5a>
movzbl %sil,%edi
movzbl %dl,%edx
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <proc_type_std@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @process_std(i32 %0, i8 zeroext %1, i8 zeroext %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store i32 %3, i32* %8
store i32 0, i32* %10
%11 = load i32, i32* %8
switch i32 %11, label %44 [
i32 4, label %12
]
12: ; preds = %4
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = load i8, i8* %6
%17 = load i8, i8* %7
%18 = call i32 @proc_type_std(i8 zeroext %16, i32 0, i8 zeroext %17)
store i32 %18, i32* %10
br label %43
19: ; preds = %12
store i32 0, i32* %9
br label %20
20: ; preds = %39, %19
%21 = load i32, i32* %9
%22 = icmp slt i32 %21, 16
br i1 %22, label %23, label %42
23: ; preds = %20
%24 = load i32, i32* %5
%25 = load i32, i32* %9
%26 = shl i32 1, %25
%27 = and i32 %24, %26
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %38
29: ; preds = %23
%30 = load i8, i8* %6
%31 = load i32, i32* %9
%32 = load i8, i8* %7
%33 = call i32 @proc_type_std(i8 zeroext %30, i32 %31, i8 zeroext %32)
store i32 %33, i32* %10
%34 = load i32, i32* %10
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %29
br label %42
37: ; preds = %29
br label %38
38: ; preds = %37, %23
br label %39
39: ; preds = %38
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %20
42: ; preds = %36, %20
br label %43
43: ; preds = %42, %15
br label %44
44: ; preds = %4, %43
%45 = load i32, i32* %10
ret i32 %45
}

LLVM IR (-O2):
define i32 @process_std(i32 %0, i8 zeroext %1, i8 zeroext %2, i32 %3) {
%5 = icmp eq i32 %3, 4
br i1 %5, label %6, label %21
6: ; preds = %4
%7 = icmp eq i32 %0, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @proc_type_std(i8 zeroext %1, i32 0, i8 zeroext %2)
br label %21
10: ; preds = %6, %18
%11 = phi i32 [ %19, %18 ], [ 0, %6 ]
%12 = shl nuw nsw i32 1, %11
%13 = and i32 %12, %0
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = tail call i32 @proc_type_std(i8 zeroext %1, i32 %11, i8 zeroext %2)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %10, %15
%19 = add nuw nsw i32 %11, 1
%20 = icmp eq i32 %19, 16
br i1 %20, label %21, label %10
21: ; preds = %15, %18, %8, %4
%22 = phi i32 [ %9, %8 ], [ 0, %4 ], [ 0, %18 ], [ %16, %15 ]
ret i32 %22
}