#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*/ ping_helper(int);
int /*<<< orphan*/ pthread_exit(int /*<<< orphan*/ *);
void *ping_thread(void *tid) {
  int i, step, first, last;
  step = 254 / 254 + 1;
  if (254 % 254 == 0) {
    --step;
  }
  first = *((int *)tid) * step + 1;
  last = first + step;
  last = (last > 255) ? 255 : last;
  for (i = first; i < last; ++i) {
    ping_helper(i);
  }
  pthread_exit(NULL);
}


x86 assembly (clang, -O0):
<ping_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
imul   -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0xff,-0x20(%rbp)
jle    116f <ping_thread+0x4f>
mov    $0xff,%eax
mov    %eax,-0x24(%rbp)
jmp    1175 <ping_thread+0x55>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11a3 <ping_thread+0x83>
mov    -0x14(%rbp),%edi
call   1030 <ping_helper@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1181 <ping_thread+0x61>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ping_thread>:
push   %rax
mov    (%rdi),%edi
cmp    $0xfd,%edi
jg     1133 <ping_thread+0x13>
add    $0x1,%edi
call   1030 <ping_helper@plt>
xor    %edi,%edi
pop    %rax
jmp    1040 <pthread_exit@plt>

LLVM IR (-O0):
define i8* @ping_thread(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 2, i32* %5
%8 = load i32, i32* %5
%9 = add nsw i32 %8, -1
store i32 %9, i32* %5
%10 = load i8*, i8** %3
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
%13 = load i32, i32* %5
%14 = mul nsw i32 %12, %13
%15 = add nsw i32 %14, 1
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = load i32, i32* %5
%18 = add nsw i32 %16, %17
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp sgt i32 %19, 255
br i1 %20, label %21, label %22
21: ; preds = %1
br label %24
22: ; preds = %1
%23 = load i32, i32* %7
br label %24
24: ; preds = %22, %21
%25 = phi i32 [ 255, %21 ], [ %23, %22 ]
store i32 %25, i32* %7
%26 = load i32, i32* %6
store i32 %26, i32* %4
br label %27
27: ; preds = %34, %24
%28 = load i32, i32* %4
%29 = load i32, i32* %7
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %37
31: ; preds = %27
%32 = load i32, i32* %4
%33 = call i32 @ping_helper(i32 %32)
br label %34
34: ; preds = %31
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %27
37: ; preds = %27
%38 = call i32 @pthread_exit(i32* null)
%39 = load i8*, i8** %2
ret i8* %39
}

LLVM IR (-O2):
define noalias i8* @ping_thread(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
%4 = icmp sgt i32 %3, 253
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = add nsw i32 %3, 1
%7 = tail call i32 @ping_helper(i32 %6)
br label %8
8: ; preds = %5, %1
%9 = tail call i32 @pthread_exit(i32* null)
ret i8* undef
}