#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  char *tm_hour;
  char *tm_min;
  int /*<<< orphan*/ tm_sec;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, char *, char *, char *, int,
                           int, int, char *, char *, int /*<<< orphan*/, char *,
                           char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *TesteFimAFim(int sessao, char *codigo_ativacao, char *dados_venda) {
  char *cod = "";
  char *mensagem_sefaz = "";
  char *conteudo_cfe = "<CFe>...</CFe>";
  char *num_doc_fiscal = "000001";
  char *chave_consulta = "CFe12345678901234567890123456789012345678901234";
  time_t t = time(NULL);
  struct tm tm = *localtime(&t);
  static char resp[512];
  sprintf(resp,
          "%d|09000|Emitido com sucesso|"
          "%s|%s|%s|"
          "%04d%02d%02d%02d%02d%02d|%s|%s",
          sessao, cod, mensagem_sefaz, conteudo_cfe, tm.tm_year + 1900,
          tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
          num_doc_fiscal, chave_consulta);
  return resp;
}


x86 assembly (clang, -O0):
<TesteFimAFim>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %edi,-0x2c(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
lea    0xeaf(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xea4(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe84(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe88(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe84(%rip),%rax
mov    %rax,-0x68(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x6c(%rbp)
lea    -0x6c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rsi
lea    -0x98(%rbp),%rdi
mov    $0x28,%edx
call   1040 <memcpy@plt>
mov    -0x2c(%rbp),%edx
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    -0x98(%rbp),%r13d
add    $0x76c,%r13d
mov    -0x94(%rbp),%r12d
add    $0x1,%r12d
mov    -0x90(%rbp),%r15d
mov    -0x88(%rbp),%r14
mov    -0x80(%rbp),%rbx
mov    -0x78(%rbp),%r11d
mov    -0x60(%rbp),%r10
mov    -0x68(%rbp),%rax
lea    0x2e44(%rip),%rdi
lea    0xe33(%rip),%rsi
mov    %r13d,(%rsp)
mov    %r12d,0x8(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11d,0x28(%rsp)
mov    %r10,0x30(%rsp)
mov    %rax,0x38(%rsp)
call   1060 <sprintf@plt>
lea    0x2e0a(%rip),%rax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<TesteFimAFim>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ebp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x44(%rsp)
lea    0x44(%rsp),%rdi
call   1030 <localtime@plt>
mov    0x4(%rax),%ecx
mov    0x8(%rax),%edx
movups 0x10(%rax),%xmm0
mov    0x20(%rax),%esi
mov    $0x76c,%edi
add    (%rax),%edi
add    $0x1,%ecx
lea    0xeab(%rip),%rax
mov    %rax,0x38(%rsp)
lea    0xe98(%rip),%rax
mov    %rax,0x30(%rsp)
mov    %esi,0x28(%rsp)
movups %xmm0,0x18(%rsp)
mov    %edx,0x10(%rsp)
mov    %ecx,0x8(%rsp)
mov    %edi,(%rsp)
lea    0x2eb9(%rip),%rbx
lea    0xea8(%rip),%rsi
lea    0xe70(%rip),%rcx
lea    0xe54(%rip),%r9
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %rcx,%r8
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i8*, i8*, i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [15 x i8] c"<CFe>...</CFe>\00"
@.str.2 = [7 x i8] c"000001\00"
@.str.3 = [48 x i8] c"CFe12345678901234567890123456789012345678901234\00"
@TesteFimAFim.resp = internal global [512 x i8] zeroinitializer
@.str.4 = [69 x i8] c"%d|09000|Emitido com sucesso|%s|%s|%s|%04d%02d%02d%02d%02d%02d|%s|%s\00"
define i8* @TesteFimAFim(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca %struct.tm
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8** %11
%14 = call i32 @time(i32* null)
store i32 %14, i32* %12
%15 = call %struct.tm* @localtime(i32* %12)
%16 = bitcast %struct.tm* %13 to i8*
%17 = bitcast %struct.tm* %15 to i8*
%18 = load i32, i32* %4
%19 = load i8*, i8** %7
%20 = load i8*, i8** %8
%21 = load i8*, i8** %9
%22 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 0
%23 = load i32, i32* %22
%24 = add nsw i32 %23, 1900
%25 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 1
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
%28 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 2
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 3
%31 = load i8*, i8** %30
%32 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 4
%33 = load i8*, i8** %32
%34 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 5
%35 = load i32, i32* %34
%36 = load i8*, i8** %10
%37 = load i8*, i8** %11
%38 = call i32 @sprintf(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @TesteFimAFim.resp, i64 0, i64 0), i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0), i32 %18, i8* %19, i8* %20, i8* %21, i32 %24, i32 %27, i32 %29, i8* %31, i8* %33, i32 %35, i8* %36, i8* %37)
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @TesteFimAFim.resp, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i8*, i8*, i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [15 x i8] c"<CFe>...</CFe>\00"
@.str.2 = [7 x i8] c"000001\00"
@.str.3 = [48 x i8] c"CFe12345678901234567890123456789012345678901234\00"
@TesteFimAFim.resp = internal global [512 x i8] zeroinitializer
@.str.4 = [69 x i8] c"%d|09000|Emitido com sucesso|%s|%s|%s|%04d%02d%02d%02d%02d%02d|%s|%s\00"
define i8* @TesteFimAFim(i32 %0, i8* nocapture readnone %1, i8* nocapture readnone %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i32 @time(i32* null)
store i32 %6, i32* %4
%7 = call %struct.tm* @localtime(i32* %4)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 3
%15 = load i8*, i8** %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 4
%17 = load i8*, i8** %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 5
%19 = load i32, i32* %18
%20 = add nsw i32 %9, 1900
%21 = add nsw i32 %11, 1
%22 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([512 x i8], [512 x i8]* @TesteFimAFim.resp, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.4, i64 0, i64 0), i32 %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %21, i32 %13, i8* %15, i8* %17, i32 %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @TesteFimAFim.resp, i64 0, i64 0)
}