#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 */

/* Variables and functions */
int /*<<< orphan*/ aprs_processreceivedline(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *strdup(char *);
int /*<<< orphan*/ strlen(char *);
char *strtok(char *, char *);
int main(void) {
  char *buf2 = "HA5KDR>APRS,TCPIP*,qAC,SIXTH::HA2NON-7 :teszt 1 2 3{01}";
  char *buf = strdup(buf2);
  char *tok;
  tok = strtok(buf, "\n");
  while (tok != NULL) {
    aprs_processreceivedline(tok, strlen(tok));
    tok = strtok(NULL, "\n");
  }
  free(buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11cb <main+0x7b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1060 <aprs_processreceivedline@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe7b(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    118b <main+0x3b>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xea4(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,%r14
lea    0xecd(%rip),%rsi
mov    %rax,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     11b4 <main+0x64>
mov    %rax,%rbx
lea    0xeb6(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <aprs_processreceivedline@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1190 <main+0x40>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [56 x i8] c"HA5KDR>APRS,TCPIP*,qAC,SIXTH::HA2NON-7 :teszt 1 2 3{01}\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strdup(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %8, i8** %4
br label %9
9: ; preds = %12, %0
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i8*, i8** %4
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @aprs_processreceivedline(i8* %13, i32 %15)
%17 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %17, i8** %4
br label %9
18: ; preds = %9
%19 = load i8*, i8** %3
%20 = call i32 @free(i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [56 x i8] c"HA5KDR>APRS,TCPIP*,qAC,SIXTH::HA2NON-7 :teszt 1 2 3{01}\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(56) i8* @strdup(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* @strtok(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %10, label %4
4: ; preds = %0, %4
%5 = phi i8* [ %8, %4 ], [ %2, %0 ]
%6 = tail call i32 @strlen(i8* %5)
%7 = tail call i32 @aprs_processreceivedline(i8* %5, i32 %6)
%8 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %4
10: ; preds = %4, %0
%11 = tail call i32 @free(i8* %1)
ret i32 0
}