#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 */
struct txstate {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ txsenddata(struct txstate *);
int /*<<< orphan*/ txsendsymbols(struct txstate *, unsigned char *, int);
int /*<<< orphan*/ txsendtrain(struct txstate *);
void modmodulate(void *state, unsigned int txdelay) {
  struct txstate *tx = (struct txstate *)state;
  unsigned char txddata[(((((48) * 8)) + (3) - 1) / (3))];
  unsigned int i, j, k;
  if (txdelay > 0) {
    for (i = j = k = 0; i < (((((48) * 8)) + (3) - 1) / (3)); i++) {
      if (j < 3) {
        k |= 0x7e << j;
        j += 8;
      }
      txddata[i] = k & ((1 << (3)) - 1);
      k >>= 3;
      j -= 3;
    }
  }
  while (txdelay > 0) {
    txsendtrain(tx);
    txsendsymbols(tx, txddata, (((((48) * 8)) + (3) - 1) / (3)));
    if (txdelay > ((16 + (((((48) * 8)) + (3) - 1) / (3))) * 1000 / 2400))
      txdelay -= ((16 + (((((48) * 8)) + (3) - 1) / (3))) * 1000 / 2400);
    else
      txdelay = 0;
  }
  txsendtrain(tx);
  while (!txsenddata(tx))
    ;
}


x86 assembly (clang, -O0):
<modmodulate>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jbe    1206 <modmodulate+0xd6>
movl   $0x0,-0xac(%rbp)
movl   $0x0,-0xa8(%rbp)
movl   $0x0,-0xa4(%rbp)
cmpl   $0x80,-0xa4(%rbp)
jae    1201 <modmodulate+0xd1>
cmpl   $0x3,-0xa8(%rbp)
jae    11b7 <modmodulate+0x87>
mov    -0xa8(%rbp),%ecx
mov    $0x7e,%eax
shl    %cl,%eax
or     -0xac(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0xa8(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xa8(%rbp)
mov    -0xac(%rbp),%eax
and    $0x7,%eax
mov    %al,%cl
mov    -0xa4(%rbp),%eax
mov    %cl,-0xa0(%rbp,%rax,1)
mov    -0xac(%rbp),%eax
shr    $0x3,%eax
mov    %eax,-0xac(%rbp)
mov    -0xa8(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0xa8(%rbp)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1172 <modmodulate+0x42>
jmp    1206 <modmodulate+0xd6>
jmp    120b <modmodulate+0xdb>
cmpl   $0x0,-0xc(%rbp)
jbe    1257 <modmodulate+0x127>
mov    -0x18(%rbp),%rdi
call   1050 <txsendtrain@plt>
mov    -0x18(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   1040 <txsendsymbols@plt>
cmpl   $0x3c,-0xc(%rbp)
jbe    124b <modmodulate+0x11b>
mov    -0xc(%rbp),%eax
sub    $0x3c,%eax
mov    %eax,-0xc(%rbp)
jmp    1252 <modmodulate+0x122>
movl   $0x0,-0xc(%rbp)
jmp    120b <modmodulate+0xdb>
mov    -0x18(%rbp),%rdi
call   1050 <txsendtrain@plt>
mov    -0x18(%rbp),%rdi
call   1030 <txsenddata@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    127e <modmodulate+0x14e>
jmp    1283 <modmodulate+0x153>
jmp    1260 <modmodulate+0x130>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modmodulate>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%r12
test   %esi,%esi
je     11e1 <modmodulate+0xb1>
mov    %esi,%ebp
xor    %r8d,%r8d
xor    %edx,%edx
xor    %esi,%esi
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x7e,%eax
shl    %cl,%eax
lea    0x8(%rcx),%edi
cmp    $0x3,%ecx
cmovae %ecx,%edi
cmovae %r8d,%eax
or     %esi,%eax
lea    -0x3(%rdi),%ecx
mov    $0x7e,%esi
shl    %cl,%esi
mov    %eax,%ebx
and    $0x7,%bl
shr    $0x3,%eax
add    $0x5,%edi
cmp    $0x3,%ecx
cmovae %ecx,%edi
cmovae %r8d,%esi
mov    %bl,(%rsp,%rdx,1)
or     %eax,%esi
mov    %esi,%eax
and    $0x7,%al
mov    %al,0x1(%rsp,%rdx,1)
shr    $0x3,%esi
add    $0xfffffffd,%edi
add    $0x2,%rdx
mov    %edi,%ecx
cmp    $0x80,%rdx
jne    1160 <modmodulate+0x30>
mov    %rsp,%r14
xor    %r15d,%r15d
nopl   (%rax)
mov    %r12,%rdi
call   1050 <txsendtrain@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x80,%edx
call   1040 <txsendsymbols@plt>
sub    $0x3c,%ebp
cmovb  %r15d,%ebp
ja     11c0 <modmodulate+0x90>
mov    %r12,%rdi
call   1050 <txsendtrain@plt>
nopl   0x0(%rax)
mov    %r12,%rdi
call   1030 <txsenddata@plt>
test   %eax,%eax
je     11f0 <modmodulate+0xc0>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.txstate = type { i32 }
define void @modmodulate(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.txstate*
%6 = alloca [128 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%10 = load i8*, i8** %3
%11 = bitcast i8* %10 to %struct.txstate*
store %struct.txstate* %11, %struct.txstate** %5
%12 = load i32, i32* %4
%13 = icmp ugt i32 %12, 0
br i1 %13, label %14, label %43
14: ; preds = %2
store i32 0, i32* %9
store i32 0, i32* %8
store i32 0, i32* %7
br label %15
15: ; preds = %39, %14
%16 = load i32, i32* %7
%17 = icmp ult i32 %16, 128
br i1 %17, label %18, label %42
18: ; preds = %15
%19 = load i32, i32* %8
%20 = icmp ult i32 %19, 3
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* %8
%23 = shl i32 126, %22
%24 = load i32, i32* %9
%25 = or i32 %24, %23
store i32 %25, i32* %9
%26 = load i32, i32* %8
%27 = add i32 %26, 8
store i32 %27, i32* %8
br label %28
28: ; preds = %21, %18
%29 = load i32, i32* %9
%30 = and i32 %29, 7
%31 = trunc i32 %30 to i8
%32 = load i32, i32* %7
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 %33
store i8 %31, i8* %34
%35 = load i32, i32* %9
%36 = lshr i32 %35, 3
store i32 %36, i32* %9
%37 = load i32, i32* %8
%38 = sub i32 %37, 3
store i32 %38, i32* %8
br label %39
39: ; preds = %28
%40 = load i32, i32* %7
%41 = add i32 %40, 1
store i32 %41, i32* %7
br label %15
42: ; preds = %15
br label %43
43: ; preds = %42, %2
br label %44
44: ; preds = %59, %43
%45 = load i32, i32* %4
%46 = icmp ugt i32 %45, 0
br i1 %46, label %47, label %60
47: ; preds = %44
%48 = load %struct.txstate*, %struct.txstate** %5
%49 = call i32 @txsendtrain(%struct.txstate* %48)
%50 = load %struct.txstate*, %struct.txstate** %5
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%52 = call i32 @txsendsymbols(%struct.txstate* %50, i8* %51, i32 128)
%53 = load i32, i32* %4
%54 = icmp ugt i32 %53, 60
br i1 %54, label %55, label %58
55: ; preds = %47
%56 = load i32, i32* %4
%57 = sub i32 %56, 60
store i32 %57, i32* %4
br label %59
58: ; preds = %47
store i32 0, i32* %4
br label %59
59: ; preds = %58, %55
br label %44
60: ; preds = %44
%61 = load %struct.txstate*, %struct.txstate** %5
%62 = call i32 @txsendtrain(%struct.txstate* %61)
br label %63
63: ; preds = %68, %60
%64 = load %struct.txstate*, %struct.txstate** %5
%65 = call i32 @txsenddata(%struct.txstate* %64)
%66 = icmp ne i32 %65, 0
%67 = xor i1 %66, true
br i1 %67, label %68, label %69
68: ; preds = %63
br label %63
69: ; preds = %63
ret void
}

LLVM IR (-O2):
%struct.txstate = type { i32 }
define void @modmodulate(i8* %0, i32 %1) {
%3 = alloca [128 x i8]
%4 = bitcast i8* %0 to %struct.txstate*
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32 %1, 0
br i1 %6, label %42, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %34, %7 ], [ 0, %2 ]
%9 = phi i32 [ %32, %7 ], [ 0, %2 ]
%10 = phi i32 [ %33, %7 ], [ 0, %2 ]
%11 = icmp ult i32 %10, 3
%12 = shl i32 126, %10
%13 = add i32 %10, 8
%14 = select i1 %11, i32 %13, i32 %10
%15 = select i1 %11, i32 %12, i32 0
%16 = or i32 %15, %9
%17 = trunc i32 %16 to i8
%18 = and i8 %17, 7
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %8
store i8 %18, i8* %19
%20 = lshr i32 %16, 3
%21 = add i32 %14, -3
%22 = or i64 %8, 1
%23 = icmp ult i32 %21, 3
%24 = shl i32 126, %21
%25 = add i32 %14, 5
%26 = select i1 %23, i32 %25, i32 %21
%27 = select i1 %23, i32 %24, i32 0
%28 = or i32 %27, %20
%29 = trunc i32 %28 to i8
%30 = and i8 %29, 7
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %22
store i8 %30, i8* %31
%32 = lshr i32 %28, 3
%33 = add i32 %26, -3
%34 = add nuw nsw i64 %8, 2
%35 = icmp eq i64 %34, 128
br i1 %35, label %36, label %7
36: ; preds = %7, %36
%37 = phi i32 [ %40, %36 ], [ %1, %7 ]
%38 = call i32 @txsendtrain(%struct.txstate* %4)
%39 = call i32 @txsendsymbols(%struct.txstate* %4, i8* %5, i32 128)
%40 = call i32 @llvm.usub.sat.i32(i32 %37, i32 60)
%41 = icmp ult i32 %37, 61
br i1 %41, label %42, label %36
42: ; preds = %36, %2
%43 = call i32 @txsendtrain(%struct.txstate* %4)
br label %44
44: ; preds = %44, %42
%45 = call i32 @txsenddata(%struct.txstate* %4)
%46 = icmp eq i32 %45, 0
br i1 %46, label %44, label %47
47: ; preds = %44
ret void
}