#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*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ uint16_t;
typedef int int32_t;

/* Variables and functions */
int UINT16_MAX;
int UINT32_MAX;
int UINT8_MAX;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int32_t mut_get_ins_bytes(int32_t n) {
  int32_t num_bytes = 1;
  if (n <= UINT8_MAX)
    num_bytes += sizeof(uint8_t);
  else if (n <= UINT16_MAX)
    num_bytes += sizeof(uint16_t);
  else if (n <= UINT32_MAX)
    num_bytes += sizeof(uint32_t);
  else {
    fprintf(stderr, "UINT32_MAX < n");
    exit(1);
  }
  num_bytes += ((n + 3) >> 2);
  return num_bytes;
}


x86 assembly (clang, -O0):
<mut_get_ins_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%eax
jg     1154 <mut_get_ins_bytes+0x34>
movslq -0x8(%rbp),%rax
add    $0x4,%rax
mov    %eax,-0x8(%rbp)
jmp    11c1 <mut_get_ins_bytes+0xa1>
mov    -0x4(%rbp),%eax
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%eax
jg     1176 <mut_get_ins_bytes+0x56>
movslq -0x8(%rbp),%rax
add    $0x4,%rax
mov    %eax,-0x8(%rbp)
jmp    11bc <mut_get_ins_bytes+0x9c>
mov    -0x4(%rbp),%eax
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%eax
jg     1198 <mut_get_ins_bytes+0x78>
movslq -0x8(%rbp),%rax
add    $0x4,%rax
mov    %eax,-0x8(%rbp)
jmp    11b7 <mut_get_ins_bytes+0x97>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    11bc <mut_get_ins_bytes+0x9c>
jmp    11c1 <mut_get_ins_bytes+0xa1>
mov    -0x4(%rbp),%eax
add    $0x3,%eax
sar    $0x2,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mut_get_ins_bytes>:
push   %rax
mov    0x2ea8(%rip),%rax
cmp    %edi,(%rax)
jge    1142 <mut_get_ins_bytes+0x22>
mov    0x2e95(%rip),%rax
cmp    %edi,(%rax)
jge    1142 <mut_get_ins_bytes+0x22>
mov    0x2eba(%rip),%rax
cmp    %edi,(%rax)
jl     114f <mut_get_ins_bytes+0x2f>
add    $0x3,%edi
sar    $0x2,%edi
add    $0x5,%edi
mov    %edi,%eax
pop    %rcx
ret
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@UINT8_MAX = global i32 0
@UINT16_MAX = global i32 0
@UINT32_MAX = global i32 0
@stderr = global i32 0
@.str = [15 x i8] c"UINT32_MAX < n\00"
define i32 @mut_get_ins_bytes(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* @UINT8_MAX
%6 = icmp sle i32 %4, %5
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = add i64 %9, 4
%11 = trunc i64 %10 to i32
store i32 %11, i32* %3
br label %36
12: ; preds = %1
%13 = load i32, i32* %2
%14 = load i32, i32* @UINT16_MAX
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = add i64 %18, 4
%20 = trunc i64 %19 to i32
store i32 %20, i32* %3
br label %35
21: ; preds = %12
%22 = load i32, i32* %2
%23 = load i32, i32* @UINT32_MAX
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = add i64 %27, 4
%29 = trunc i64 %28 to i32
store i32 %29, i32* %3
br label %34
30: ; preds = %21
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %25
br label %35
35: ; preds = %34, %16
br label %36
36: ; preds = %35, %7
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 3
%39 = ashr i32 %38, 2
%40 = load i32, i32* %3
%41 = add nsw i32 %40, %39
store i32 %41, i32* %3
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@UINT8_MAX = global i32 0
@UINT16_MAX = global i32 0
@UINT32_MAX = global i32 0
@stderr = global i32 0
@.str = [15 x i8] c"UINT32_MAX < n\00"
define i32 @mut_get_ins_bytes(i32 %0) {
%2 = load i32, i32* @UINT8_MAX
%3 = icmp slt i32 %2, %0
%4 = load i32, i32* @UINT16_MAX
%5 = icmp slt i32 %4, %0
%6 = select i1 %3, i1 %5, i1 false
%7 = load i32, i32* @UINT32_MAX
%8 = icmp slt i32 %7, %0
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %1
%15 = add nsw i32 %0, 3
%16 = ashr i32 %15, 2
%17 = add nsw i32 %16, 5
ret i32 %17
}