#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 uint8_t;
typedef int uint64_t;
typedef int uint32_t;
typedef int size;

/* Variables and functions */
void set_atom_size(unsigned char *header, uint32_t header_size, uint64_t size) {
  switch (header_size) {
  case 8: {
    ((uint8_t *)(header))[0] = ((size) >> 24) & 0xff;
    ((uint8_t *)(header))[1] = ((size) >> 16) & 0xff;
    ((uint8_t *)(header))[2] = ((size) >> 8) & 0xff;
    ((uint8_t *)(header))[3] = (size)&0xff;
  }; break;
  case 16: {
    {
      ((uint8_t *)(header + 8))[0] = (((size) >> 32) >> 24) & 0xff;
      ((uint8_t *)(header + 8))[1] = (((size) >> 32) >> 16) & 0xff;
      ((uint8_t *)(header + 8))[2] = (((size) >> 32) >> 8) & 0xff;
      ((uint8_t *)(header + 8))[3] = ((size) >> 32) & 0xff;
    }
    {
      ((uint8_t *)(header + 8 + 4))[0] = ((size) >> 24) & 0xff;
      ((uint8_t *)(header + 8 + 4))[1] = ((size) >> 16) & 0xff;
      ((uint8_t *)(header + 8 + 4))[2] = ((size) >> 8) & 0xff;
      ((uint8_t *)(header + 8 + 4))[3] = (size)&0xff;
    }
  }; break;
  }
}


x86 assembly (clang, -O0):
<set_atom_size>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x8,%eax
je     1133 <set_atom_size+0x33>
jmp    1122 <set_atom_size+0x22>
mov    -0x14(%rbp),%eax
sub    $0x10,%eax
je     1180 <set_atom_size+0x80>
jmp    1236 <set_atom_size+0x136>
mov    -0x10(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
jmp    1236 <set_atom_size+0x136>
mov    -0x10(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x10(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x10(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x10(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x10(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_atom_size>:
cmp    $0x8,%esi
je     1120 <set_atom_size+0x20>
cmp    $0x10,%esi
jne    1154 <set_atom_size+0x54>
lea    0xc(%rdi),%rax
mov    $0x18,%r8d
mov    $0x14,%ecx
mov    $0x10,%esi
jmp    1133 <set_atom_size+0x33>
mov    $0xc,%r8d
mov    $0x8,%ecx
mov    $0x4,%esi
mov    %rdi,%rax
push   %rbx
mov    %edx,%ebx
shr    $0x18,%ebx
mov    %ebx,(%rax)
mov    %edx,%eax
shr    $0x10,%eax
movzbl %al,%eax
mov    %eax,(%rdi,%rsi,1)
movzbl %dh,%eax
mov    %eax,(%rdi,%rcx,1)
movzbl %dl,%eax
mov    %eax,(%rdi,%r8,1)
pop    %rbx
ret

LLVM IR (-O0):
define void @set_atom_size(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
switch i32 %7, label %95 [
i32 8, label %8
i32 16, label %32
]
8: ; preds = %3
%9 = load i32, i32* %6
%10 = ashr i32 %9, 24
%11 = and i32 %10, 255
%12 = load i8*, i8** %4
%13 = bitcast i8* %12 to i32*
%14 = getelementptr inbounds i32, i32* %13, i64 0
store i32 %11, i32* %14
%15 = load i32, i32* %6
%16 = ashr i32 %15, 16
%17 = and i32 %16, 255
%18 = load i8*, i8** %4
%19 = bitcast i8* %18 to i32*
%20 = getelementptr inbounds i32, i32* %19, i64 1
store i32 %17, i32* %20
%21 = load i32, i32* %6
%22 = ashr i32 %21, 8
%23 = and i32 %22, 255
%24 = load i8*, i8** %4
%25 = bitcast i8* %24 to i32*
%26 = getelementptr inbounds i32, i32* %25, i64 2
store i32 %23, i32* %26
%27 = load i32, i32* %6
%28 = and i32 %27, 255
%29 = load i8*, i8** %4
%30 = bitcast i8* %29 to i32*
%31 = getelementptr inbounds i32, i32* %30, i64 3
store i32 %28, i32* %31
br label %95
32: ; preds = %3
%33 = load i32, i32* %6
%34 = ashr i32 %33, 32
%35 = ashr i32 %34, 24
%36 = and i32 %35, 255
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 8
%39 = bitcast i8* %38 to i32*
%40 = getelementptr inbounds i32, i32* %39, i64 0
store i32 %36, i32* %40
%41 = load i32, i32* %6
%42 = ashr i32 %41, 32
%43 = ashr i32 %42, 16
%44 = and i32 %43, 255
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 8
%47 = bitcast i8* %46 to i32*
%48 = getelementptr inbounds i32, i32* %47, i64 1
store i32 %44, i32* %48
%49 = load i32, i32* %6
%50 = ashr i32 %49, 32
%51 = ashr i32 %50, 8
%52 = and i32 %51, 255
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i64 8
%55 = bitcast i8* %54 to i32*
%56 = getelementptr inbounds i32, i32* %55, i64 2
store i32 %52, i32* %56
%57 = load i32, i32* %6
%58 = ashr i32 %57, 32
%59 = and i32 %58, 255
%60 = load i8*, i8** %4
%61 = getelementptr inbounds i8, i8* %60, i64 8
%62 = bitcast i8* %61 to i32*
%63 = getelementptr inbounds i32, i32* %62, i64 3
store i32 %59, i32* %63
%64 = load i32, i32* %6
%65 = ashr i32 %64, 24
%66 = and i32 %65, 255
%67 = load i8*, i8** %4
%68 = getelementptr inbounds i8, i8* %67, i64 8
%69 = getelementptr inbounds i8, i8* %68, i64 4
%70 = bitcast i8* %69 to i32*
%71 = getelementptr inbounds i32, i32* %70, i64 0
store i32 %66, i32* %71
%72 = load i32, i32* %6
%73 = ashr i32 %72, 16
%74 = and i32 %73, 255
%75 = load i8*, i8** %4
%76 = getelementptr inbounds i8, i8* %75, i64 8
%77 = getelementptr inbounds i8, i8* %76, i64 4
%78 = bitcast i8* %77 to i32*
%79 = getelementptr inbounds i32, i32* %78, i64 1
store i32 %74, i32* %79
%80 = load i32, i32* %6
%81 = ashr i32 %80, 8
%82 = and i32 %81, 255
%83 = load i8*, i8** %4
%84 = getelementptr inbounds i8, i8* %83, i64 8
%85 = getelementptr inbounds i8, i8* %84, i64 4
%86 = bitcast i8* %85 to i32*
%87 = getelementptr inbounds i32, i32* %86, i64 2
store i32 %82, i32* %87
%88 = load i32, i32* %6
%89 = and i32 %88, 255
%90 = load i8*, i8** %4
%91 = getelementptr inbounds i8, i8* %90, i64 8
%92 = getelementptr inbounds i8, i8* %91, i64 4
%93 = bitcast i8* %92 to i32*
%94 = getelementptr inbounds i32, i32* %93, i64 3
store i32 %89, i32* %94
br label %95
95: ; preds = %3, %32, %8
ret void
}

LLVM IR (-O2):
define void @set_atom_size(i8* nocapture writeonly %0, i32 %1, i32 %2) {
switch i32 %1, label %24 [
i32 8, label %6
i32 16, label %4
]
4: ; preds = %3
%5 = getelementptr inbounds i8, i8* %0, i64 12
br label %6
6: ; preds = %3, %4
%7 = phi i8* [ %5, %4 ], [ %0, %3 ]
%8 = phi i64 [ 16, %4 ], [ 4, %3 ]
%9 = phi i64 [ 20, %4 ], [ 8, %3 ]
%10 = phi i64 [ 24, %4 ], [ 12, %3 ]
%11 = lshr i32 %2, 24
%12 = bitcast i8* %7 to i32*
store i32 %11, i32* %12
%13 = lshr i32 %2, 16
%14 = and i32 %13, 255
%15 = getelementptr inbounds i8, i8* %0, i64 %8
%16 = bitcast i8* %15 to i32*
store i32 %14, i32* %16
%17 = lshr i32 %2, 8
%18 = and i32 %17, 255
%19 = getelementptr inbounds i8, i8* %0, i64 %9
%20 = bitcast i8* %19 to i32*
store i32 %18, i32* %20
%21 = and i32 %2, 255
%22 = getelementptr inbounds i8, i8* %0, i64 %10
%23 = bitcast i8* %22 to i32*
store i32 %21, i32* %23
br label %24
24: ; preds = %6, %3
ret void
}