#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 blkpg_partition {
  int pno;
  scalar_t__ *volname;
  scalar_t__ *devname;
  scalar_t__ length;
  scalar_t__ start;
};
struct blkpg_ioctl_arg {
  int datalen;
  struct blkpg_partition *data;
  scalar_t__ flags;
  int /*<<< orphan*/ op;
};
typedef int /*<<< orphan*/ p;

/* Variables and functions */
int /*<<< orphan*/ BLKPG;
int /*<<< orphan*/ BLKPG_DEL_PARTITION;
int ioctl(int, int /*<<< orphan*/, struct blkpg_ioctl_arg *);
int partx_del_partition(int fd, int partno) {
  struct blkpg_ioctl_arg a;
  struct blkpg_partition p;
  p.pno = partno;
  p.start = 0;
  p.length = 0;
  p.devname[0] = 0;
  p.volname[0] = 0;
  a.op = BLKPG_DEL_PARTITION;
  a.flags = 0;
  a.datalen = sizeof(p);
  a.data = &p;
  return ioctl(fd, BLKPG, &a);
}


x86 assembly (clang, -O0):
<partx_del_partition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x50(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x40(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x48(%rbp),%rax
movq   $0x0,(%rax)
mov    0x2e97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x28,-0x28(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1030 <ioctl@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
%struct.blkpg_ioctl_arg = type { i32, %struct.blkpg_partition*, i64, i32 }
%struct.blkpg_partition = type { i32, i64*, i64*, i64, i64 }
@BLKPG_DEL_PARTITION = global i32 0
@BLKPG = global i32 0
define i32 @partx_del_partition(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.blkpg_ioctl_arg
%6 = alloca %struct.blkpg_partition
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = getelementptr inbounds %struct.blkpg_partition, %struct.blkpg_partition* %6, i32 0, i32 0
store i32 %7, i32* %8
%9 = getelementptr inbounds %struct.blkpg_partition, %struct.blkpg_partition* %6, i32 0, i32 4
store i64 0, i64* %9
%10 = getelementptr inbounds %struct.blkpg_partition, %struct.blkpg_partition* %6, i32 0, i32 3
store i64 0, i64* %10
%11 = getelementptr inbounds %struct.blkpg_partition, %struct.blkpg_partition* %6, i32 0, i32 2
%12 = load i64*, i64** %11
%13 = getelementptr inbounds i64, i64* %12, i64 0
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.blkpg_partition, %struct.blkpg_partition* %6, i32 0, i32 1
%15 = load i64*, i64** %14
%16 = getelementptr inbounds i64, i64* %15, i64 0
store i64 0, i64* %16
%17 = load i32, i32* @BLKPG_DEL_PARTITION
%18 = getelementptr inbounds %struct.blkpg_ioctl_arg, %struct.blkpg_ioctl_arg* %5, i32 0, i32 3
store i32 %17, i32* %18
%19 = getelementptr inbounds %struct.blkpg_ioctl_arg, %struct.blkpg_ioctl_arg* %5, i32 0, i32 2
store i64 0, i64* %19
%20 = getelementptr inbounds %struct.blkpg_ioctl_arg, %struct.blkpg_ioctl_arg* %5, i32 0, i32 0
store i32 40, i32* %20
%21 = getelementptr inbounds %struct.blkpg_ioctl_arg, %struct.blkpg_ioctl_arg* %5, i32 0, i32 1
store %struct.blkpg_partition* %6, %struct.blkpg_partition** %21
%22 = load i32, i32* %3
%23 = load i32, i32* @BLKPG
%24 = call i32 @ioctl(i32 %22, i32 %23, %struct.blkpg_ioctl_arg* %5)
ret i32 %24
}

LLVM IR (-O2):