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

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int strlen(char const *);
char *strptime(char const *, char *, struct tm *);
int do_test(void) {
  struct tm t;
  const char *in = "Tuesday \t 22 \t July\t1942";
  char *r = strptime(in, "%A%d %b%Y", &t);
  if (r == NULL || r != in + strlen(in)) {
    printf("strptime failed\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xec1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xecb(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <strptime@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1198 <do_test+0x68>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rcx
mov    %eax,%edx
mov    -0x20(%rbp),%rax
movslq %edx,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
je     11b0 <do_test+0x80>
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b7 <do_test+0x87>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%r14
lea    0xed7(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
call   1050 <strptime@plt>
test   %rax,%rax
je     1167 <do_test+0x37>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
add    %r14,%rax
cmp    %rax,%rbx
je     117a <do_test+0x4a>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    117c <do_test+0x4c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [25 x i8] c"Tuesday \09 22 \09 July\091942\00"
@.str.1 = [10 x i8] c"%A%d %b%Y\00"
@.str.2 = [17 x i8] c"strptime failed\0A\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca %struct.tm
%3 = alloca i8*
%4 = alloca i8*
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @strptime(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %2)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %17, label %9
9: ; preds = %0
%10 = load i8*, i8** %4
%11 = load i8*, i8** %3
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %11, i64 %14
%16 = icmp ne i8* %10, %15
br i1 %16, label %17, label %19
17: ; preds = %9, %0
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %20
19: ; preds = %9
store i32 0, i32* %1
br label %20
20: ; preds = %19, %17
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [25 x i8] c"Tuesday \09 22 \09 July\091942\00"
@.str.1 = [10 x i8] c"%A%d %b%Y\00"
@str = [16 x i8] c"strptime failed\00"
define i32 @do_test() {
%1 = alloca %struct.tm
%2 = bitcast %struct.tm* %1 to i8*
%3 = call i8* @strptime(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [25 x i8], [25 x i8]* @.str, i64 0, i64 %7
%9 = icmp eq i8* %3, %8
br i1 %9, label %12, label %10
10: ; preds = %5, %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %5, %10
%13 = phi i32 [ 1, %10 ], [ 0, %5 ]
ret i32 %13
}