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

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int, ...);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int getCycleTime(char *recv, int len, char *result) {
  int i;
  char string[80];
  if (len % 2) {
    sprintf(result, "Anzahl Bytes ungerade");
    return (0);
  }
  bzero(string, sizeof(string));
  for (i = 0; i < len; i += 2) {
    if (recv[i] == (char)0xff)
      snprintf(string, sizeof(string), "%d:An:--     Aus:--\n", (i / 2) + 1);
    else
      snprintf(string, sizeof(string), "%d:An:%02d:%02d  Aus:%02d:%02d\n",
               (i / 2) + 1, (recv[i] & 0xF8) >> 3, (recv[i] & 7) * 10,
               (recv[i + 1] & 0xF8) >> 3, (recv[i + 1] & 7) * 10);
    strcat(result, string);
  }
  result[strlen(result) - 1] = '\0';
  return (1);
}


x86 assembly (clang, -O0):
<getCycleTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1196 <getCycleTime+0x46>
mov    -0x20(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12cf <getCycleTime+0x17f>
lea    -0x80(%rbp),%rdi
mov    $0x50,%esi
call   1050 <bzero@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12a1 <getCycleTime+0x151>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xffffffff,%eax
jne    11f8 <getCycleTime+0xa8>
lea    -0x80(%rbp),%rdi
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
add    $0x1,%ecx
mov    $0x50,%esi
lea    0xe2a(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    1286 <getCycleTime+0x136>
lea    -0x80(%rbp),%rdi
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rdx
movsbl (%rax,%rdx,1),%r8d
and    $0xf8,%r8d
sar    $0x3,%r8d
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rdx
movsbl (%rax,%rdx,1),%eax
and    $0x7,%eax
imul   $0xa,%eax,%r9d
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movsbl (%rax,%rdx,1),%r10d
and    $0xf8,%r10d
sar    $0x3,%r10d
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movsbl (%rax,%rdx,1),%eax
and    $0x7,%eax
imul   $0xa,%eax,%eax
mov    $0x50,%esi
lea    0xdb4(%rip),%rdx
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    11ab <getCycleTime+0x5b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCycleTime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdx,%rbx
mov    %esi,%r15d
test   $0x1,%r15b
jne    1216 <getCycleTime+0xd6>
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x50,%esi
call   1050 <bzero@plt>
test   %r15d,%r15d
jle    1232 <getCycleTime+0xf2>
mov    $0x1,%ebp
mov    %rsp,%r13
xor    %r12d,%r12d
jmp    11f0 <getCycleTime+0xb0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%r8d
shr    $0x3,%r8d
and    $0x7,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%r9d
movzbl 0x1(%r14,%r12,1),%eax
mov    %rbx,%r11
mov    %eax,%ebx
shr    $0x3,%ebx
and    $0x7,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%r10d
mov    %r13,%rdi
mov    $0x50,%esi
lea    0xe65(%rip),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
push   %r10
push   %rbx
mov    %r11,%rbx
call   1040 <snprintf@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
add    $0x2,%r12
add    $0x1,%ebp
cmp    %r15d,%r12d
jge    1232 <getCycleTime+0xf2>
movzbl (%r14,%r12,1),%eax
cmp    $0xff,%eax
jne    1190 <getCycleTime+0x50>
mov    %r13,%rdi
mov    $0x50,%esi
lea    0xe0b(%rip),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    11d9 <getCycleTime+0x99>
movups 0xde3(%rip),%xmm0
movups %xmm0,(%rbx)
movabs $0x6564617265676e,%rax
mov    %rax,0xe(%rbx)
xor    %eax,%eax
jmp    1246 <getCycleTime+0x106>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    $0x1,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Anzahl Bytes ungerade\00"
@.str.1 = [21 x i8] c"%d:An:-- Aus:--\0A\00"
@.str.2 = [32 x i8] c"%d:An:%02d:%02d Aus:%02d:%02d\0A\00"
define i32 @getCycleTime(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [80 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%10 = load i32, i32* %6
%11 = srem i32 %10, 2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i8*, i8** %7
%15 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %91
16: ; preds = %3
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%18 = call i32 @bzero(i8* %17, i32 80)
store i32 0, i32* %8
br label %19
19: ; preds = %81, %16
%20 = load i32, i32* %8
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %84
23: ; preds = %19
%24 = load i8*, i8** %5
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %37
31: ; preds = %23
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%33 = load i32, i32* %8
%34 = sdiv i32 %33, 2
%35 = add nsw i32 %34, 1
%36 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %32, i32 80, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %77
37: ; preds = %23
%38 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%39 = load i32, i32* %8
%40 = sdiv i32 %39, 2
%41 = add nsw i32 %40, 1
%42 = load i8*, i8** %5
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = and i32 %47, 248
%49 = ashr i32 %48, 3
%50 = load i8*, i8** %5
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = and i32 %55, 7
%57 = mul nsw i32 %56, 10
%58 = load i8*, i8** %5
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %58, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = and i32 %64, 248
%66 = ashr i32 %65, 3
%67 = load i8*, i8** %5
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = and i32 %73, 7
%75 = mul nsw i32 %74, 10
%76 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %38, i32 80, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %41, i32 %49, i32 %57, i32 %66, i32 %75)
br label %77
77: ; preds = %37, %31
%78 = load i8*, i8** %7
%79 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%80 = call i32 @strcat(i8* %78, i8* %79)
br label %81
81: ; preds = %77
%82 = load i32, i32* %8
%83 = add nsw i32 %82, 2
store i32 %83, i32* %8
br label %19
84: ; preds = %19
%85 = load i8*, i8** %7
%86 = load i8*, i8** %7
%87 = call i32 @strlen(i8* %86)
%88 = sub nsw i32 %87, 1
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %85, i64 %89
store i8 0, i8* %90
store i32 1, i32* %4
br label %91
91: ; preds = %84, %13
%92 = load i32, i32* %4
ret i32 %92
}

LLVM IR (-O2):
@.str = [22 x i8] c"Anzahl Bytes ungerade\00"
@.str.1 = [21 x i8] c"%d:An:-- Aus:--\0A\00"
@.str.2 = [32 x i8] c"%d:An:%02d:%02d Aus:%02d:%02d\0A\00"
define i32 @getCycleTime(i8* nocapture %0, i32 %1, i8* %2) {
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%6 = and i32 %1, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %3
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(22) %2, i8* align 1 dereferenceable(22) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 22, i1 false)
br label %47
9: ; preds = %3
%10 = call i32 @bzero(i8* %5, i32 80)
%11 = icmp sgt i32 %1, 0
br i1 %11, label %12, label %42
12: ; preds = %9, %37
%13 = phi i64 [ %39, %37 ], [ 0, %9 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = icmp eq i8 %15, -1
%18 = lshr exact i64 %13, 1
br i1 %17, label %19, label %23
19: ; preds = %12
%20 = trunc i64 %18 to i32
%21 = add i32 %20, 1
%22 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %5, i32 80, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %37
23: ; preds = %12
%24 = lshr i32 %16, 3
%25 = and i32 %16, 7
%26 = mul nuw nsw i32 %25, 10
%27 = or i64 %13, 1
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = lshr i32 %30, 3
%32 = and i32 %30, 7
%33 = mul nuw nsw i32 %32, 10
%34 = trunc i64 %18 to i32
%35 = add i32 %34, 1
%36 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %5, i32 80, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %24, i32 %26, i32 %31, i32 %33)
br label %37
37: ; preds = %23, %19
%38 = call i32 @strcat(i8* %2, i8* %5)
%39 = add nuw i64 %13, 2
%40 = trunc i64 %39 to i32
%41 = icmp slt i32 %40, %1
br i1 %41, label %12, label %42
42: ; preds = %37, %9
%43 = call i32 @strlen(i8* %2)
%44 = add nsw i32 %43, -1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %2, i64 %45
store i8 0, i8* %46
br label %47
47: ; preds = %42, %8
%48 = phi i32 [ 0, %8 ], [ 1, %42 ]
ret i32 %48
}