#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 */
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, int, char *,
                           char *);
char *getpid();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int vis5d_debug_msg(char *msg) {
  struct timeval tv;
  char str0[2];
  gettimeofday(&tv, 0);
  strcpy(str0, "");
  if (msg != 0) {
    if (msg[0] == '\n') {
      strcpy(str0, "\n");
      msg++;
    }
  }
  fprintf(stderr, "%s%4.4d.%6.6d   pid=%d   %s", str0, (tv.tv_sec % 10000),
          tv.tv_usec, getpid(), msg);
  fflush(stderr);
  return 1;
}


x86 assembly (clang, -O0):
<vis5d_debug_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    -0x12(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1030 <strcpy@plt>
cmpq   $0x0,-0x8(%rbp)
je     11b3 <vis5d_debug_msg+0x63>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11ae <vis5d_debug_msg+0x5e>
lea    -0x12(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <vis5d_debug_msg+0x63>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x12(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    %rax,%r9
mov    -0x8(%rbp),%rax
lea    0xe04(%rip),%rsi
mov    %rax,(%rsp)
call   1060 <fprintf@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vis5d_debug_msg>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0xe8f(%rip),%rsi
lea    0x16(%rsp),%rdi
call   1030 <strcpy@plt>
test   %rbx,%rbx
je     119d <vis5d_debug_msg+0x4d>
cmpb   $0xa,(%rbx)
jne    119f <vis5d_debug_msg+0x4f>
lea    0xe73(%rip),%rsi
lea    0x16(%rsp),%rdi
call   1030 <strcpy@plt>
add    $0x1,%rbx
jmp    119f <vis5d_debug_msg+0x4f>
xor    %ebx,%ebx
mov    0x2e3a(%rip),%r12
mov    (%r12),%r14d
movslq 0x18(%rsp),%rbp
imul   $0x68db8bad,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebp
mov    0x1c(%rsp),%r15d
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rbx,(%rsp)
lea    0xe20(%rip),%rsi
lea    0x16(%rsp),%rdx
mov    %r14d,%edi
mov    %ebp,%ecx
mov    %r15d,%r8d
mov    %rax,%r9
call   1060 <fprintf@plt>
mov    (%r12),%edi
call   1070 <fflush@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"\0A\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"%s%4.4d.%6.6d pid=%d %s\00"
define i32 @vis5d_debug_msg(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.timeval
%4 = alloca [2 x i8]
store i8* %0, i8** %2
%5 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %2
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %22
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %2
br label %21
21: ; preds = %16, %10
br label %22
22: ; preds = %21, %1
%23 = load i32, i32* @stderr
%24 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%26 = load i32, i32* %25
%27 = srem i32 %26, 10000
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%29 = load i32, i32* %28
%30 = call i8* (...) @getpid()
%31 = load i8*, i8** %2
%32 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %24, i32 %27, i32 %29, i8* %30, i8* %31)
%33 = load i32, i32* @stderr
%34 = call i32 @fflush(i32 %33)
ret i32 1
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"\0A\00"
@stderr = global i32 0
@.str.2 = [28 x i8] c"%s%4.4d.%6.6d pid=%d %s\00"
define i32 @vis5d_debug_msg(i8* %0) {
%2 = alloca %struct.timeval
%3 = alloca [2 x i8]
%4 = bitcast %struct.timeval* %2 to i8*
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%6 = call i32 @gettimeofday(%struct.timeval* %2, i32 0)
%7 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %0, null
br i1 %8, label %15, label %9
9: ; preds = %1
%10 = load i8, i8* %0
%11 = icmp eq i8 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds i8, i8* %0, i64 1
br label %15
15: ; preds = %9, %12, %1
%16 = phi i8* [ %14, %12 ], [ %0, %9 ], [ null, %1 ]
%17 = load i32, i32* @stderr
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%19 = load i32, i32* %18
%20 = srem i32 %19, 10000
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%22 = load i32, i32* %21
%23 = call i8* (...) @getpid()
%24 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 %20, i32 %22, i8* %23, i8* %16)
%25 = load i32, i32* @stderr
%26 = call i32 @fflush(i32 %25)
ret i32 1
}