#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 */
char *strchr(char *, char);
int extract_tstamp(char *buffer, char *host) {
  int j;
  char *p = NULL;
  if ((p = strchr(buffer, ';')) != NULL) {
    if (*p != '\0')
      p++;
    else
      return 0;
    if (*p == ' ')
      p++;
    else
      return 0;
    for (j = 0; *p != '\0' && *p != '\n'; p++, j++)
      host[j] = *p;
    host[j] = '\0';
  }
  return 0;
}


x86 assembly (clang, -O0):
<extract_tstamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3b,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1211 <extract_tstamp+0x101>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1165 <extract_tstamp+0x55>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1171 <extract_tstamp+0x61>
movl   $0x0,-0x4(%rbp)
jmp    1218 <extract_tstamp+0x108>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1192 <extract_tstamp+0x82>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    119e <extract_tstamp+0x8e>
movl   $0x0,-0x4(%rbp)
jmp    1218 <extract_tstamp+0x108>
movl   $0x0,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     11ca <extract_tstamp+0xba>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11da <extract_tstamp+0xca>
jmp    1205 <extract_tstamp+0xf5>
mov    -0x28(%rbp),%rax
mov    (%rax),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a5 <extract_tstamp+0x95>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_tstamp>:
push   %rbx
mov    %rsi,%rbx
mov    $0x3b,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     114d <extract_tstamp+0x3d>
cmpb   $0x0,(%rax)
je     114d <extract_tstamp+0x3d>
cmpb   $0x20,0x1(%rax)
jne    114d <extract_tstamp+0x3d>
xor    %ecx,%ecx
movzbl 0x2(%rax,%rcx,1),%edx
test   %dl,%dl
je     1147 <extract_tstamp+0x37>
cmp    $0xa,%dl
je     1147 <extract_tstamp+0x37>
mov    %dl,(%rbx,%rcx,1)
add    $0x1,%rcx
jmp    1130 <extract_tstamp+0x20>
mov    %ecx,%eax
movb   $0x0,(%rbx,%rax,1)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @extract_tstamp(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %7
%8 = load i8*, i8** %4
%9 = call i8* @strchr(i8* %8, i8 signext 59)
store i8* %9, i8** %7
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %59
11: ; preds = %2
%12 = load i8*, i8** %7
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %7
br label %20
19: ; preds = %11
store i32 0, i32* %3
br label %60
20: ; preds = %16
%21 = load i8*, i8** %7
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 32
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %7
br label %29
28: ; preds = %20
store i32 0, i32* %3
br label %60
29: ; preds = %25
store i32 0, i32* %6
br label %30
30: ; preds = %49, %29
%31 = load i8*, i8** %7
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %30
%36 = load i8*, i8** %7
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 10
br label %40
40: ; preds = %35, %30
%41 = phi i1 [ false, %30 ], [ %39, %35 ]
br i1 %41, label %42, label %54
42: ; preds = %40
%43 = load i8*, i8** %7
%44 = load i8, i8* %43
%45 = load i8*, i8** %5
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
store i8 %44, i8* %48
br label %49
49: ; preds = %42
%50 = load i8*, i8** %7
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %7
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
br label %30
54: ; preds = %40
%55 = load i8*, i8** %5
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8 0, i8* %58
br label %59
59: ; preds = %54, %2
store i32 0, i32* %3
br label %60
60: ; preds = %59, %28, %19
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
define i32 @extract_tstamp(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 59)
%4 = icmp eq i8* %3, null
br i1 %4, label %25, label %5
5: ; preds = %2
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %25, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %3, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 32
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %3, i64 2
br label %14
14: ; preds = %18, %12
%15 = phi i64 [ %21, %18 ], [ 0, %12 ]
%16 = phi i8* [ %20, %18 ], [ %13, %12 ]
%17 = load i8, i8* %16
switch i8 %17, label %18 [
i8 0, label %22
i8 10, label %22
]
18: ; preds = %14
%19 = getelementptr inbounds i8, i8* %1, i64 %15
store i8 %17, i8* %19
%20 = getelementptr inbounds i8, i8* %16, i64 1
%21 = add nuw i64 %15, 1
br label %14
22: ; preds = %14, %14
%23 = and i64 %15, 4294967295
%24 = getelementptr inbounds i8, i8* %1, i64 %23
store i8 0, i8* %24
br label %25
25: ; preds = %2, %22, %8, %5
ret i32 0
}