#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 */
float atof(char *);
int atoi(char *);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
int /*<<< orphan*/ printf(char *, char *, ...);
char *strtok(char *, char *);
int decode_line(char t[], int tam) {
  char *pch;
  char sensor[6], tmp[6];
  int mod, porta;
  float value;
  pch = strtok(t, ":");
  if (pch != NULL) {
    memcpy(sensor, pch, 6);
    printf("Sensor: %s\n", sensor);
    pch = strtok(NULL, ":");
    memcpy(tmp, pch, (size_t)15);
    value = atof(tmp);
    printf("Value: %s; %2.2f\n", tmp, value);
    pch = strtok(NULL, ":");
    memcpy(tmp, pch, (size_t)5);
    mod = atoi(tmp);
    printf("Mod: %s; %d\n", tmp, mod);
  }
  return 0;
}


x86 assembly (clang, -O0):
<decode_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1238 <decode_line+0xe8>
lea    -0x1e(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x6,%edx
call   1050 <memcpy@plt>
lea    -0x1e(%rbp),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe53(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    -0x24(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xf,%edx
call   1050 <memcpy@plt>
lea    -0x24(%rbp),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x30(%rbp)
lea    -0x24(%rbp),%rsi
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe04(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    -0x24(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x5,%edx
call   1050 <memcpy@plt>
lea    -0x24(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x28(%rbp)
lea    -0x24(%rbp),%rsi
mov    -0x28(%rbp),%edx
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_line>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xea2(%rip),%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     120a <decode_line+0xba>
lea    0x12(%rsp),%rbx
mov    $0x6,%edx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <memcpy@plt>
lea    0xe7a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe67(%rip),%r14
xor    %edi,%edi
mov    %r14,%rsi
call   1060 <strtok@plt>
lea    0xc(%rsp),%rbx
mov    $0xf,%edx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <memcpy@plt>
mov    %rbx,%rdi
call   1030 <atof@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe43(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1060 <strtok@plt>
mov    $0x5,%edx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <memcpy@plt>
mov    %rbx,%rdi
call   1070 <atoi@plt>
lea    0xe22(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [12 x i8] c"Sensor: %s\0A\00"
@.str.2 = [18 x i8] c"Value: %s; %2.2f\0A\00"
@.str.3 = [13 x i8] c"Mod: %s; %d\0A\00"
define i32 @decode_line(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [6 x i8]
%7 = alloca [6 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
store i8* %0, i8** %3
store i32 %1, i32* %4
%11 = load i8*, i8** %3
%12 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %40
15: ; preds = %2
%16 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %5
%18 = call i32 @memcpy(i8* %16, i8* %17, i64 6)
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%20 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %5
%22 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%23 = load i8*, i8** %5
%24 = call i32 @memcpy(i8* %22, i8* %23, i64 15)
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%26 = call float @atof(i8* %25)
store float %26, float* %10
%27 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%28 = load float, float* %10
%29 = fpext float %28 to double
%30 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %27, double %29)
%31 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %31, i8** %5
%32 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%33 = load i8*, i8** %5
%34 = call i32 @memcpy(i8* %32, i8* %33, i64 5)
%35 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %8
%37 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%38 = load i32, i32* %8
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %37, i32 %38)
br label %40
40: ; preds = %15, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [12 x i8] c"Sensor: %s\0A\00"
@.str.2 = [18 x i8] c"Value: %s; %2.2f\0A\00"
@.str.3 = [13 x i8] c"Mod: %s; %d\0A\00"
define i32 @decode_line(i8* %0, i32 %1) {
%3 = alloca [6 x i8]
%4 = alloca [6 x i8]
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%7 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %21, label %9
9: ; preds = %2
%10 = call i32 @memcpy(i8* %5, i8* %7, i64 6)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%12 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @memcpy(i8* %6, i8* %12, i64 15)
%14 = call float @atof(i8* %6)
%15 = fpext float %14 to double
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %6, double %15)
%17 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @memcpy(i8* %6, i8* %17, i64 5)
%19 = call i32 @atoi(i8* %6)
%20 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %6, i32 %19)
br label %21
21: ; preds = %9, %2
ret i32 0
}