#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 tstamp {
  int dummy;
};

/* Variables and functions */
int decode_timestamp(char *, struct tstamp *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char *);
int parse_timestamp(char *argv[], int *opt, struct tstamp *tse,
                    const char *def_timestamp) {
  char timestamp[9];
  if ((argv[++(*opt)]) && (strlen(argv[*opt]) == 8)) {
    strcpy(timestamp, argv[(*opt)++]);
  } else {
    strcpy(timestamp, def_timestamp);
  }
  return decode_timestamp(timestamp, tse);
}


x86 assembly (clang, -O0):
<parse_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdx
mov    (%rdx),%ecx
add    $0x1,%ecx
mov    %ecx,(%rdx)
movslq %ecx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11a8 <parse_timestamp+0x78>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
cmp    $0x8,%eax
jne    11a8 <parse_timestamp+0x78>
lea    -0x29(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdx
mov    (%rdx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
jmp    11b5 <parse_timestamp+0x85>
lea    -0x29(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x29(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <decode_timestamp@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_timestamp>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rdi,%r12
movslq (%rsi),%rax
lea    0x1(%rax),%rcx
mov    %ecx,(%rsi)
mov    0x8(%rdi,%rax,8),%rdi
test   %rdi,%rdi
je     1170 <parse_timestamp+0x40>
mov    %rsi,%rbx
call   1050 <strlen@plt>
cmp    $0x8,%eax
jne    1170 <parse_timestamp+0x40>
movslq (%rbx),%rax
lea    0x1(%rax),%ecx
mov    %ecx,(%rbx)
mov    (%r12,%rax,8),%r15
lea    0xf(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <decode_timestamp@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tstamp = type { i32 }
define i32 @parse_timestamp(i8** %0, i32* %1, %struct.tstamp* %2, i8* %3) {
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.tstamp*
%8 = alloca i8*
%9 = alloca [9 x i8]
store i8** %0, i8*** %5
store i32* %1, i32** %6
store %struct.tstamp* %2, %struct.tstamp** %7
store i8* %3, i8** %8
%10 = load i8**, i8*** %5
%11 = load i32*, i32** %6
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
store i32 %13, i32* %11
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %10, i64 %14
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %37
18: ; preds = %4
%19 = load i8**, i8*** %5
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %19, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @strlen(i8* %24)
%26 = icmp eq i32 %25, 8
br i1 %26, label %27, label %37
27: ; preds = %18
%28 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%29 = load i8**, i8*** %5
%30 = load i32*, i32** %6
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds i8*, i8** %29, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @strcpy(i8* %28, i8* %35)
br label %41
37: ; preds = %18, %4
%38 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%39 = load i8*, i8** %8
%40 = call i32 @strcpy(i8* %38, i8* %39)
br label %41
41: ; preds = %37, %27
%42 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%43 = load %struct.tstamp*, %struct.tstamp** %7
%44 = call i32 @decode_timestamp(i8* %42, %struct.tstamp* %43)
ret i32 %44
}

LLVM IR (-O2):
%struct.tstamp = type { i32 }
define i32 @parse_timestamp(i8** nocapture %0, i32* nocapture %1, %struct.tstamp* %2, i8* %3) {
%5 = alloca [9 x i8]
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%7 = load i32, i32* %1
%8 = add nsw i32 %7, 1
store i32 %8, i32* %1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8*, i8** %0, i64 %9
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %22, label %13
13: ; preds = %4
%14 = tail call i32 @strlen(i8* %11)
%15 = icmp eq i32 %14, 8
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32, i32* %1
%18 = add nsw i32 %17, 1
store i32 %18, i32* %1
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i8*, i8** %0, i64 %19
%21 = load i8*, i8** %20
br label %22
22: ; preds = %4, %13, %16
%23 = phi i8* [ %21, %16 ], [ %3, %13 ], [ %3, %4 ]
%24 = call i32 @strcpy(i8* %6, i8* %23)
%25 = call i32 @decode_timestamp(i8* %6, %struct.tstamp* %2)
ret i32 %25
}