#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 cjobinfo {
  int dummy;
};
typedef int /*<<< orphan*/ errm;

/* Variables and functions */
int /*<<< orphan*/ ctl_freeinf(struct cjobinfo *);
char *ctl_getline(struct cjobinfo *);
struct cjobinfo *ctl_readcf(char const *, char const *);
int /*<<< orphan*/ ctl_rewindcf(struct cjobinfo *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
char *strdup(char *);
char *ctl_rmjob(const char *ptrname, const char *cfname) {
  struct cjobinfo *cjinf;
  char *lbuff;
  char errm[1024 + 1025 + 5];
  cjinf = ctl_readcf(ptrname, cfname);
  if (cjinf == NULL) {
    snprintf(errm, sizeof(errm), "ctl_renametf error cti_readcf(%s)", cfname);
    return strdup(errm);
  }
  ctl_rewindcf(cjinf);
  lbuff = ctl_getline(cjinf);
  while (lbuff != NULL) {
    switch (lbuff[0]) {
    case 'S':
      break;
    case 'U':
      break;
    default:
      break;
    }
    lbuff = ctl_getline(cjinf);
  }
  ctl_freeinf(cjinf);
  cjinf = NULL;
  return NULL;
}


x86 assembly (clang, -O0):
<ctl_rmjob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <ctl_readcf@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c0 <ctl_rmjob+0x60>
lea    -0x830(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x806,%esi
lea    0xe5a(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x830(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    124a <ctl_rmjob+0xea>
mov    -0x20(%rbp),%rdi
call   1050 <ctl_rewindcf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <ctl_getline@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1231 <ctl_rmjob+0xd1>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x834(%rbp)
sub    $0x53,%eax
je     1210 <ctl_rmjob+0xb0>
jmp    11fc <ctl_rmjob+0x9c>
mov    -0x834(%rbp),%eax
sub    $0x55,%eax
je     1215 <ctl_rmjob+0xb5>
jmp    121a <ctl_rmjob+0xba>
jmp    121f <ctl_rmjob+0xbf>
jmp    121f <ctl_rmjob+0xbf>
jmp    121f <ctl_rmjob+0xbf>
mov    -0x20(%rbp),%rdi
call   1060 <ctl_getline@plt>
mov    %rax,-0x28(%rbp)
jmp    11d6 <ctl_rmjob+0x76>
mov    -0x20(%rbp),%rdi
call   1040 <ctl_freeinf@plt>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ctl_rmjob>:
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%r14
call   1070 <ctl_readcf@plt>
test   %rax,%rax
je     11a9 <ctl_rmjob+0x49>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <ctl_rewindcf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <ctl_getline@plt>
test   %rax,%rax
jne    1190 <ctl_rmjob+0x30>
mov    %rbx,%rdi
call   1040 <ctl_freeinf@plt>
xor    %eax,%eax
jmp    11cb <ctl_rmjob+0x6b>
lea    0xe50(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x806,%esi
mov    %r14,%rcx
call   1030 <snprintf@plt>
mov    %rbx,%rdi
call   1080 <strdup@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.cjobinfo = type { i32 }
@.str = [34 x i8] c"ctl_renametf error cti_readcf(%s)\00"
define i8* @ctl_rmjob(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.cjobinfo*
%7 = alloca i8*
%8 = alloca [2054 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call %struct.cjobinfo* @ctl_readcf(i8* %9, i8* %10)
store %struct.cjobinfo* %11, %struct.cjobinfo** %6
%12 = load %struct.cjobinfo*, %struct.cjobinfo** %6
%13 = icmp eq %struct.cjobinfo* %12, null
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = getelementptr inbounds [2054 x i8], [2054 x i8]* %8, i64 0, i64 0
%16 = load i8*, i8** %5
%17 = call i32 @snprintf(i8* %15, i32 2054, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [2054 x i8], [2054 x i8]* %8, i64 0, i64 0
%19 = call i8* @strdup(i8* %18)
store i8* %19, i8** %3
br label %42
20: ; preds = %2
%21 = load %struct.cjobinfo*, %struct.cjobinfo** %6
%22 = call i32 @ctl_rewindcf(%struct.cjobinfo* %21)
%23 = load %struct.cjobinfo*, %struct.cjobinfo** %6
%24 = call i8* @ctl_getline(%struct.cjobinfo* %23)
store i8* %24, i8** %7
br label %25
25: ; preds = %36, %20
%26 = load i8*, i8** %7
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
switch i32 %32, label %35 [
i32 83, label %33
i32 85, label %34
]
33: ; preds = %28
br label %36
34: ; preds = %28
br label %36
35: ; preds = %28
br label %36
36: ; preds = %35, %34, %33
%37 = load %struct.cjobinfo*, %struct.cjobinfo** %6
%38 = call i8* @ctl_getline(%struct.cjobinfo* %37)
store i8* %38, i8** %7
br label %25
39: ; preds = %25
%40 = load %struct.cjobinfo*, %struct.cjobinfo** %6
%41 = call i32 @ctl_freeinf(%struct.cjobinfo* %40)
store %struct.cjobinfo* null, %struct.cjobinfo** %6
store i8* null, i8** %3
br label %42
42: ; preds = %39, %14
%43 = load i8*, i8** %3
ret i8* %43
}

LLVM IR (-O2):
%struct.cjobinfo = type { i32 }
@.str = [34 x i8] c"ctl_renametf error cti_readcf(%s)\00"
define noalias i8* @ctl_rmjob(i8* %0, i8* %1) {
%3 = alloca [2054 x i8]
%4 = getelementptr inbounds [2054 x i8], [2054 x i8]* %3, i64 0, i64 0
%5 = tail call %struct.cjobinfo* @ctl_readcf(i8* %0, i8* %1)
%6 = icmp eq %struct.cjobinfo* %5, null
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = call i32 @snprintf(i8* %4, i32 2054, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %1)
%9 = call i8* @strdup(i8* %4)
br label %19
10: ; preds = %2
%11 = tail call i32 @ctl_rewindcf(%struct.cjobinfo* %5)
%12 = tail call i8* @ctl_getline(%struct.cjobinfo* %5)
%13 = icmp eq i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %10, %14
%15 = tail call i8* @ctl_getline(%struct.cjobinfo* %5)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %14
17: ; preds = %14, %10
%18 = tail call i32 @ctl_freeinf(%struct.cjobinfo* %5)
br label %19
19: ; preds = %17, %7
%20 = phi i8* [ %9, %7 ], [ null, %17 ]
ret i8* %20
}