#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 */
unsigned long do_div(unsigned long long, int);
int /*<<< orphan*/ trace_printk(char *, unsigned long, unsigned long,
                                unsigned int, unsigned int, unsigned int,
                                unsigned int, ...);
void ms_th(unsigned long long timestamp, unsigned char cnt,
           unsigned int *value) {
  unsigned long nano_rem = do_div(timestamp, 1000000000);
  switch (cnt) {
  case 4:
    trace_printk("%5lu.%06lu"
                 ",%d,%d,%d,%d\n",
                 (unsigned long)(timestamp), nano_rem / 1000, value[0],
                 value[1], value[2], value[3]);
    break;
  case 7:
    trace_printk("%5lu.%06lu"
                 ",%d,%d,%d,%d,%d,%d,%d\n",
                 (unsigned long)(timestamp), nano_rem / 1000, value[0],
                 value[1], value[2], value[3], value[4], value[5], value[6]);
    break;
  }
}


x86 assembly (clang, -O0):
<ms_th>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x48,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3b9aca00,%esi
call   1030 <do_div@plt>
mov    %rax,-0x28(%rbp)
movzbl -0x11(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x4,%eax
je     116f <ms_th+0x4f>
jmp    115e <ms_th+0x3e>
mov    -0x2c(%rbp),%eax
sub    $0x7,%eax
je     11b7 <ms_th+0x97>
jmp    121f <ms_th+0xff>
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%eax
lea    0xe58(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <trace_printk@plt>
jmp    121f <ms_th+0xff>
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%ebx
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r11d
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%r10d
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%eax
lea    0xe11(%rip),%rdi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1040 <trace_printk@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<ms_th>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    $0x3b9aca00,%esi
call   1030 <do_div@plt>
cmp    $0x7,%bpl
je     1184 <ms_th+0x64>
cmp    $0x4,%bpl
jne    11cc <ms_th+0xac>
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
shr    $0x4,%rdx
mov    (%rbx),%ecx
mov    0x4(%rbx),%r8d
mov    0x8(%rbx),%r9d
mov    0xc(%rbx),%ebp
sub    $0x8,%rsp
lea    0xe8d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
push   %rbp
call   1040 <trace_printk@plt>
add    $0x10,%rsp
jmp    11cc <ms_th+0xac>
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
shr    $0x4,%rdx
mov    (%rbx),%ecx
mov    0x4(%rbx),%r8d
mov    0x8(%rbx),%r9d
mov    0xc(%rbx),%r10d
mov    0x10(%rbx),%r11d
mov    0x14(%rbx),%ebp
mov    0x18(%rbx),%ebx
lea    0xe60(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
push   %rbx
push   %rbp
push   %r11
push   %r10
call   1040 <trace_printk@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"%5lu.%06lu,%d,%d,%d,%d\0A\00"
@.str.1 = [33 x i8] c"%5lu.%06lu,%d,%d,%d,%d,%d,%d,%d\0A\00"
define void @ms_th(i64 %0, i8 zeroext %1, i32* %2) {
%4 = alloca i64
%5 = alloca i8
%6 = alloca i32*
%7 = alloca i64
store i64 %0, i64* %4
store i8 %1, i8* %5
store i32* %2, i32** %6
%8 = load i64, i64* %4
%9 = call i64 @do_div(i64 %8, i32 1000000000)
store i64 %9, i64* %7
%10 = load i8, i8* %5
%11 = zext i8 %10 to i32
switch i32 %11, label %55 [
i32 4, label %12
i32 7, label %29
]
12: ; preds = %3
%13 = load i64, i64* %4
%14 = load i64, i64* %7
%15 = udiv i64 %14, 1000
%16 = load i32*, i32** %6
%17 = getelementptr inbounds i32, i32* %16, i64 0
%18 = load i32, i32* %17
%19 = load i32*, i32** %6
%20 = getelementptr inbounds i32, i32* %19, i64 1
%21 = load i32, i32* %20
%22 = load i32*, i32** %6
%23 = getelementptr inbounds i32, i32* %22, i64 2
%24 = load i32, i32* %23
%25 = load i32*, i32** %6
%26 = getelementptr inbounds i32, i32* %25, i64 3
%27 = load i32, i32* %26
%28 = call i32 (i8*, i64, i64, i32, i32, i32, i32, ...) @trace_printk(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i64 %13, i64 %15, i32 %18, i32 %21, i32 %24, i32 %27)
br label %55
29: ; preds = %3
%30 = load i64, i64* %4
%31 = load i64, i64* %7
%32 = udiv i64 %31, 1000
%33 = load i32*, i32** %6
%34 = getelementptr inbounds i32, i32* %33, i64 0
%35 = load i32, i32* %34
%36 = load i32*, i32** %6
%37 = getelementptr inbounds i32, i32* %36, i64 1
%38 = load i32, i32* %37
%39 = load i32*, i32** %6
%40 = getelementptr inbounds i32, i32* %39, i64 2
%41 = load i32, i32* %40
%42 = load i32*, i32** %6
%43 = getelementptr inbounds i32, i32* %42, i64 3
%44 = load i32, i32* %43
%45 = load i32*, i32** %6
%46 = getelementptr inbounds i32, i32* %45, i64 4
%47 = load i32, i32* %46
%48 = load i32*, i32** %6
%49 = getelementptr inbounds i32, i32* %48, i64 5
%50 = load i32, i32* %49
%51 = load i32*, i32** %6
%52 = getelementptr inbounds i32, i32* %51, i64 6
%53 = load i32, i32* %52
%54 = call i32 (i8*, i64, i64, i32, i32, i32, i32, ...) @trace_printk(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i64 %30, i64 %32, i32 %35, i32 %38, i32 %41, i32 %44, i32 %47, i32 %50, i32 %53)
br label %55
55: ; preds = %3, %29, %12
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"%5lu.%06lu,%d,%d,%d,%d\0A\00"
@.str.1 = [33 x i8] c"%5lu.%06lu,%d,%d,%d,%d,%d,%d,%d\0A\00"
define void @ms_th(i64 %0, i8 zeroext %1, i32* nocapture %2) {
%4 = tail call i64 @do_div(i64 %0, i32 1000000000)
switch i8 %1, label %31 [
i8 4, label %5
i8 7, label %15
]
5: ; preds = %3
%6 = udiv i64 %4, 1000
%7 = load i32, i32* %2
%8 = getelementptr inbounds i32, i32* %2, i64 1
%9 = load i32, i32* %8
%10 = getelementptr inbounds i32, i32* %2, i64 2
%11 = load i32, i32* %10
%12 = getelementptr inbounds i32, i32* %2, i64 3
%13 = load i32, i32* %12
%14 = tail call i32 (i8*, i64, i64, i32, i32, i32, i32, ...) @trace_printk(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i64 %0, i64 %6, i32 %7, i32 %9, i32 %11, i32 %13)
br label %31
15: ; preds = %3
%16 = udiv i64 %4, 1000
%17 = load i32, i32* %2
%18 = getelementptr inbounds i32, i32* %2, i64 1
%19 = load i32, i32* %18
%20 = getelementptr inbounds i32, i32* %2, i64 2
%21 = load i32, i32* %20
%22 = getelementptr inbounds i32, i32* %2, i64 3
%23 = load i32, i32* %22
%24 = getelementptr inbounds i32, i32* %2, i64 4
%25 = load i32, i32* %24
%26 = getelementptr inbounds i32, i32* %2, i64 5
%27 = load i32, i32* %26
%28 = getelementptr inbounds i32, i32* %2, i64 6
%29 = load i32, i32* %28
%30 = tail call i32 (i8*, i64, i64, i32, i32, i32, i32, ...) @trace_printk(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i64 %0, i64 %16, i32 %17, i32 %19, i32 %21, i32 %23, i32 %25, i32 %27, i32 %29)
br label %31
31: ; preds = %3, %15, %5
ret void
}