#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 */
int /*<<< orphan*/ assert(int);
void set_present_idx(void *struct_ptr, int pres_offset, int pres_size,
                     int present) {
  void *present_ptr;
  present_ptr = ((char *)struct_ptr) + pres_offset;
  switch (pres_size) {
  case sizeof(int):
    *(int *)present_ptr = present;
    break;
  case sizeof(short):
    *(short *)present_ptr = present;
    break;
  case sizeof(char):
    *(char *)present_ptr = present;
    break;
  default:
    assert(pres_size != sizeof(int));
  }
}


x86 assembly (clang, -O0):
<set_present_idx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x1,%eax
je     118a <set_present_idx+0x7a>
jmp    1148 <set_present_idx+0x38>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
je     1178 <set_present_idx+0x68>
jmp    1159 <set_present_idx+0x49>
mov    -0x24(%rbp),%eax
sub    $0x4,%eax
jne    119a <set_present_idx+0x8a>
jmp    116a <set_present_idx+0x5a>
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    11af <set_present_idx+0x9f>
mov    -0x14(%rbp),%eax
mov    %ax,%cx
mov    -0x20(%rbp),%rax
mov    %cx,(%rax)
jmp    11af <set_present_idx+0x9f>
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
jmp    11af <set_present_idx+0x9f>
movslq -0x10(%rbp),%rax
cmp    $0x4,%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_present_idx>:
movslq %esi,%rax
cmp    $0x1,%edx
je     1126 <set_present_idx+0x16>
cmp    $0x2,%edx
je     112a <set_present_idx+0x1a>
cmp    $0x4,%edx
jne    112f <set_present_idx+0x1f>
mov    %ecx,(%rdi,%rax,1)
ret
mov    %cl,(%rdi,%rax,1)
ret
mov    %cx,(%rdi,%rax,1)
ret
setne  %al
movzbl %al,%edi
jmp    1030 <assert@plt>

LLVM IR (-O0):
define void @set_present_idx(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
store i8* %13, i8** %9
%14 = load i32, i32* %7
switch i32 %14, label %28 [
i32 4, label %15
i32 2, label %19
i32 1, label %24
]
15: ; preds = %4
%16 = load i32, i32* %8
%17 = load i8*, i8** %9
%18 = bitcast i8* %17 to i32*
store i32 %16, i32* %18
br label %34
19: ; preds = %4
%20 = load i32, i32* %8
%21 = trunc i32 %20 to i16
%22 = load i8*, i8** %9
%23 = bitcast i8* %22 to i16*
store i16 %21, i16* %23
br label %34
24: ; preds = %4
%25 = load i32, i32* %8
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %9
store i8 %26, i8* %27
br label %34
28: ; preds = %4
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = icmp ne i64 %30, 4
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
br label %34
34: ; preds = %28, %24, %19, %15
ret void
}

LLVM IR (-O2):
define void @set_present_idx(i8* nocapture writeonly %0, i32 %1, i32 %2, i32 %3) {
%5 = sext i32 %1 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
switch i32 %2, label %14 [
i32 4, label %7
i32 2, label %9
i32 1, label %12
]
7: ; preds = %4
%8 = bitcast i8* %6 to i32*
store i32 %3, i32* %8
br label %18
9: ; preds = %4
%10 = trunc i32 %3 to i16
%11 = bitcast i8* %6 to i16*
store i16 %10, i16* %11
br label %18
12: ; preds = %4
%13 = trunc i32 %3 to i8
store i8 %13, i8* %6
br label %18
14: ; preds = %4
%15 = icmp ne i32 %2, 4
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
br label %18
18: ; preds = %14, %12, %9, %7
ret void
}