#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;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, char *, char *, char *, int,
                           int, int, char *, int /*<<< orphan*/,
                           int /*<<< orphan*/, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *EnviarDadosVenda(int sessao, char *codigo_ativacao, char *dados_venda) {
  char *cod = "";
  char *mensagem_sefaz = "";
  char *conteudo_cfe = "<CFe>...</CFe>";
  char *chave_consulta = "CFe12345678901234567890123456789012345678901234";
  time_t t = time(NULL);
  struct tm tm = *localtime(&t);
  static char resp[512];
  sprintf(resp,
          "%d|06000|0000|"
          "Emitido com sucesso + conte"
          "\xc3\xba"
          "do notas|"
          "%s|%s|%s|"
          "%04d%02d%02d%02d%02d%02d|%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,
          chave_consulta);
  return resp;
}


x86 assembly (clang, -O0):
<EnviarDadosVenda>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xa0,%rsp
mov    %edi,-0x24(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
lea    0xeea(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xedf(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe96(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x58(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x5c(%rbp)
lea    -0x5c(%rbp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%rcx
mov    %rcx,-0x80(%rbp)
mov    0x8(%rax),%rcx
mov    %rcx,-0x78(%rbp)
mov    0x10(%rax),%rcx
mov    %rcx,-0x70(%rbp)
mov    0x18(%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x24(%rbp),%edx
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%r8
mov    -0x50(%rbp),%r9
mov    -0x80(%rbp),%r12d
add    $0x76c,%r12d
mov    -0x7c(%rbp),%r15d
add    $0x1,%r15d
mov    -0x78(%rbp),%r14d
mov    -0x70(%rbp),%rbx
mov    -0x64(%rbp),%r11d
mov    -0x68(%rbp),%r10d
mov    -0x58(%rbp),%rax
lea    0x2e66(%rip),%rdi
lea    0xe4e(%rip),%rsi
mov    %r12d,(%rsp)
mov    %r15d,0x8(%rsp)
mov    %r14d,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11d,0x20(%rsp)
mov    %r10d,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1050 <sprintf@plt>
lea    0x2e31(%rip),%rax
add    $0xa0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<EnviarDadosVenda>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r15d
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    0x4(%rax),%ebx
mov    0x8(%rax),%r10d
mov    0x18(%rax),%r11d
mov    0x1c(%rax),%r12d
mov    $0x76c,%ebp
add    (%rax),%ebp
add    $0x1,%ebx
sub    $0x8,%rsp
lea    0xe98(%rip),%r13
lea    0x2ed2(%rip),%r14
lea    0xeba(%rip),%rsi
lea    0xeb2(%rip),%rcx
lea    0xe6d(%rip),%r9
mov    %r14,%rdi
mov    %r15d,%edx
mov    %rcx,%r8
push   %r13
push   %r11
push   %r12
push   0x10(%rax)
push   %r10
push   %rbx
push   %rbp
call   1050 <sprintf@plt>
add    $0x40,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i8*, i32, i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [15 x i8] c"<CFe>...</CFe>\00"
@.str.2 = [48 x i8] c"CFe12345678901234567890123456789012345678901234\00"
@EnviarDadosVenda.resp = internal global [512 x i8] zeroinitializer
@.str.3 = [89 x i8] c"%d|06000|0000|Emitido com sucesso + conte\C3\BAdo notas|%s|%s|%s|%04d%02d%02d%02d%02d%02d|%s\00"
define i8* @EnviarDadosVenda(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 i32, i32* %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]* @EnviarDadosVenda.resp, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @.str.3, 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, i32 %19, i32 %17, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @EnviarDadosVenda.resp, i64 0, i64 0)
}