#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;
  char *tm_sec;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, char *, char *, char *, int,
                           int, int, char *, char *, char *, char *, char *,
                           char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *CancelarUltimaVenda(int sessao, char *codigo_ativacao, char *chave_cfe,
                          char *dados_cancelamento) {
  char *cod = "";
  char *mensagem_sefaz = "";
  char *conteudo_cfe = "<CFeCanc>...</CFeCanc>";
  char *chave_consulta = "CFe12345678901234567890123456789012345678901234";
  char *valor_total_cfe = "4.73";
  char *cpf_cnpj = "11122233396";
  char *qrcode = "RGFkb3MgUVJDb2Rl";
  time_t t = time(NULL);
  struct tm tm = *localtime(&t);
  static char resp[512];
  sprintf(resp,
          "%d|07000|0000|"
          "Cupom cancelado com sucesso + conte"
          "\xc3\xba"
          "do "
          "CF-e-SAT cancelado|"
          "%s|%s|%s|"
          "%04d%02d%02d%02d%02d%02d|%s|%s|%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,
          chave_consulta, valor_total_cfe, cpf_cnpj, qrcode);
  return resp;
}


x86 assembly (clang, -O0):
<CancelarUltimaVenda>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %edi,-0x2c(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
lea    0xee1(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xed6(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe80(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe8c(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xeb1(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xeab(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x80(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x84(%rbp)
lea    -0x84(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rsi
lea    -0xb0(%rbp),%rdi
mov    $0x28,%edx
call   1040 <memcpy@plt>
mov    -0x2c(%rbp),%edx
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    -0x60(%rbp),%r9
mov    -0xb0(%rbp),%eax
add    $0x76c,%eax
mov    -0xac(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0xbc(%rbp)
mov    -0xa8(%rbp),%r13d
mov    -0xa0(%rbp),%r12
mov    -0x98(%rbp),%r15
mov    -0x90(%rbp),%r14
mov    -0x68(%rbp),%rbx
mov    -0x70(%rbp),%r11
mov    -0x78(%rbp),%r10
mov    -0x80(%rbp),%rsi
mov    %rsi,-0xb8(%rbp)
lea    0x2e0e(%rip),%rdi
lea    0xe20(%rip),%rsi
mov    %eax,(%rsp)
mov    -0xbc(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    -0xb8(%rbp),%rax
mov    %r13d,0x10(%rsp)
mov    %r12,0x18(%rsp)
mov    %r15,0x20(%rsp)
mov    %r14,0x28(%rsp)
mov    %rbx,0x30(%rsp)
mov    %r11,0x38(%rsp)
mov    %r10,0x40(%rsp)
mov    %rax,0x48(%rsp)
call   1060 <sprintf@plt>
lea    0x2dbf(%rip),%rax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<CancelarUltimaVenda>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
mov    %edi,%ebp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x54(%rsp)
lea    0x54(%rsp),%rdi
call   1030 <localtime@plt>
mov    0x4(%rax),%ecx
mov    0x8(%rax),%edx
movups 0x10(%rax),%xmm0
mov    0x20(%rax),%rsi
mov    $0x76c,%edi
add    (%rax),%edi
add    $0x1,%ecx
lea    0xeec(%rip),%rax
mov    %rax,0x48(%rsp)
lea    0xed4(%rip),%rax
mov    %rax,0x40(%rsp)
lea    0xec3(%rip),%rax
mov    %rax,0x38(%rsp)
lea    0xe87(%rip),%rax
mov    %rax,0x30(%rsp)
mov    %rsi,0x28(%rsp)
movups %xmm0,0x18(%rsp)
mov    %edx,0x10(%rsp)
mov    %ecx,0x8(%rsp)
mov    %edi,(%rsp)
lea    0x2e9f(%rip),%rbx
lea    0xeb1(%rip),%rsi
lea    0xe8c(%rip),%rcx
lea    0xe3a(%rip),%r9
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %rcx,%r8
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i8*, i8*, i8* }
@.str = [1 x i8] zeroinitializer
@.str.1 = [23 x i8] c"<CFeCanc>...</CFeCanc>\00"
@.str.2 = [48 x i8] c"CFe12345678901234567890123456789012345678901234\00"
@.str.3 = [5 x i8] c"4.73\00"
@.str.4 = [12 x i8] c"11122233396\00"
@.str.5 = [17 x i8] c"RGFkb3MgUVJDb2Rl\00"
@CancelarUltimaVenda.resp = internal global [512 x i8] zeroinitializer
@.str.6 = [119 x i8] c"%d|07000|0000|Cupom cancelado com sucesso + conte\C3\BAdo CF-e-SAT cancelado|%s|%s|%s|%04d%02d%02d%02d%02d%02d|%s|%s|%s|%s\00"
define i8* @CancelarUltimaVenda(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca %struct.tm
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8** %11
store i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8** %12
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %13
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8** %14
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8** %15
%18 = call i32 @time(i32* null)
store i32 %18, i32* %16
%19 = call %struct.tm* @localtime(i32* %16)
%20 = bitcast %struct.tm* %17 to i8*
%21 = bitcast %struct.tm* %19 to i8*
%22 = load i32, i32* %5
%23 = load i8*, i8** %9
%24 = load i8*, i8** %10
%25 = load i8*, i8** %11
%26 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 0
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1900
%29 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 1
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
%32 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 2
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 3
%35 = load i8*, i8** %34
%36 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 4
%37 = load i8*, i8** %36
%38 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 5
%39 = load i8*, i8** %38
%40 = load i8*, i8** %12
%41 = load i8*, i8** %13
%42 = load i8*, i8** %14
%43 = load i8*, i8** %15
%44 = call i32 @sprintf(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @CancelarUltimaVenda.resp, i64 0, i64 0), i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str.6, i64 0, i64 0), i32 %22, i8* %23, i8* %24, i8* %25, i32 %28, i32 %31, i32 %33, i8* %35, i8* %37, i8* %39, i8* %40, i8* %41, i8* %42, i8* %43)
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @CancelarUltimaVenda.resp, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i8*, i8*, i8* }
@.str = [1 x i8] zeroinitializer
@.str.1 = [23 x i8] c"<CFeCanc>...</CFeCanc>\00"
@.str.2 = [48 x i8] c"CFe12345678901234567890123456789012345678901234\00"
@.str.3 = [5 x i8] c"4.73\00"
@.str.4 = [12 x i8] c"11122233396\00"
@.str.5 = [17 x i8] c"RGFkb3MgUVJDb2Rl\00"
@CancelarUltimaVenda.resp = internal global [512 x i8] zeroinitializer
@.str.6 = [119 x i8] c"%d|07000|0000|Cupom cancelado com sucesso + conte\C3\BAdo CF-e-SAT cancelado|%s|%s|%s|%04d%02d%02d%02d%02d%02d|%s|%s|%s|%s\00"
define i8* @CancelarUltimaVenda(i32 %0, i8* nocapture readnone %1, i8* nocapture readnone %2, i8* nocapture readnone %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %5
%8 = call %struct.tm* @localtime(i32* %5)
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 2
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 3
%16 = load i8*, i8** %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 4
%18 = load i8*, i8** %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 5
%20 = load i8*, i8** %19
%21 = add nsw i32 %10, 1900
%22 = add nsw i32 %12, 1
%23 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([512 x i8], [512 x i8]* @CancelarUltimaVenda.resp, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([119 x i8], [119 x i8]* @.str.6, 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 ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22, i32 %14, i8* %16, i8* %18, i8* %20, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @CancelarUltimaVenda.resp, i64 0, i64 0)
}